This is RxJS v 4. Find the latest version here
Spawns a generator function which allows for Promises, Observable sequences, Arrays, Objects, Generators and functions.
fn
(Function
): The spawning function.
(Observable
): An Observable with the final result
var Rx = require('rx');
var spawned = Rx.Observable.spawn(function* () {
var a = yield cb => cb(null, 'a');
var b = yield ['b'];
var c = yield Rx.Observable.just('c');
var d = yield Rx.Observable.just('d');
var e = yield Promise.resolve('e');
return a + b + c + d + e;
});
spawned.subscribe(
function (x) { console.log('next %s', x); },
function (e) { console.log('error %s', e); },
function () { console.log('completed'); }
);
// => next 'abcde'
// => completed
File:
Dist:
Prerequisites:
- If using
rx.async.js
|rx.async.compat.js
rx.lite.js
|rx.lite.compat.js
NPM Packages:
NuGet Packages:
Unit Tests: