Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Latest commit

 

History

History
61 lines (47 loc) · 2.34 KB

spawn.md

File metadata and controls

61 lines (47 loc) · 2.34 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: