fromCallback
Rx.Node.fromCallback(func, [scheduler], [context])
Rx.Node.fromCallback(func, [scheduler], [context])Deprecated in favor of Rx.Observable.fromCallback in rx.async.js.
Converts a callback function to an observable sequence.
Arguments
func(Function): Callback function[scheduler = Rx.Scheduler.timeout](Scheduler): Scheduler used to execute the callback.[context](Any): The context to execute the callback.
Returns
(Function): Function, when called with arguments, creates an Observable sequence from the callback.
Example
var fs = require('fs');
var Rx = require('Rx');
// Wrap exists
var exists = Rx.Node.fromCallback(fs.exists);
// Call exists
var source = exists('/etc/passwd');
var observer = Rx.Observer.create(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
}
);
var subscription = source.subscribe(observer);
// => Next: true
// => CompletedLast updated
Was this helpful?