Deprecated in favor of Rx.Observable.fromNodeCallback
in rx.async.js.
Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
func
(Function): Callback function which must be in function (err, ...) format.[scheduler = Rx.Scheduler.timeout]
(Scheduler): Scheduler used to execute the callback.[context]
(Any): The context to execute the callback.
(Function): An function which when applied, returns an observable sequence with the callback arguments as an array.
var fs = require('fs');
var Rx = require('Rx');
var source = Rx.Node.fromNodeCallback(fs.stat)('file.txt');
var observer = Rx.Observer.create(
function (x) {
var stat = x[0];
console.log('Next: ' + stat.isFile());
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
}
);
var subscription = source.subscribe(observer);
// => Next: true
// => Completed
{% if book.isPdf %}
{% else %}
- rx.node.js
{% endif %}