Rx.Observable.spawn(fn)

Spawns a generator function which allows for Promises, Observable sequences, Arrays, Objects, Generators and functions.

Arguments

  1. fn (Function): The spawning function.

Returns

(Observable): An Observable with the final result

Example

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

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests:

results matching ""

    No results matching ""