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

Latest commit

 

History

History
60 lines (46 loc) · 2.2 KB

toasync.md

File metadata and controls

60 lines (46 loc) · 2.2 KB

Rx.Observable.toAsync(func, [context], [scheduler])

Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.

Arguments

  1. func (Function): Function to convert to an asynchronous function.
  2. [context] (Any): The context for the func parameter to be executed. If not specified, defaults to undefined.
  3. [scheduler=Rx.Scheduler.timeout] (Scheduler): Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.

Returns

(Function): Asynchronous function.

Example

var func = Rx.Observable.toAsync(function (x, y) {
    return x + y;
});

// Execute function with 3 and 4
var source = func(3, 4);

var subscription = source.subscribe(
    function (x) {
        console.log('Next: ' + x);
    },
    function (err) {
        console.log('Error: ' + err);
    },
    function () {
        console.log('Completed');
    });

// => Next: 7
// => Completed

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

  • rxJS-Binding

Unit Tests: