Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 2.25 KB

spawn.md

File metadata and controls

60 lines (46 loc) · 2.25 KB

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: