Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Go to file
#1503)

There has been a LOT of confusion by RxJS users when they find the RxJS v4 docs and not v5 docs. This is to get rid of that confusion. Also updated the readme to no longer say v5 is beta, v6 will be beta pretty soon. ;)
6 contributors

Users who have contributed to this file

@mattpodwysocki @L8D @mmv @jca02266 @mixed @benlesh
68 lines (53 sloc) 2.87 KB

This is RxJS v 4. Find the latest version here

Rx.Observable.fromCallback(func, [context], [selector])

Converts a callback function to an observable sequence.

Arguments

  1. func (Function): Function with a callback as the last parameter to convert to an Observable sequence.
  2. [context] (Any): The context for the func parameter to be executed. If not specified, defaults to undefined.
  3. [selector] (Function): A selector which takes the arguments from the callback to produce a single item to yield on next.

Returns

(Function): A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array if no selector given, else the object created by the selector function.

Example

var fs = require('fs'),
    Rx = require('rx');

// Wrap fs.exists
var exists = Rx.Observable.fromCallback(fs.exists);

// Check if file.txt exists
var source = exists('file.txt');

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

// => Next: true
// => Completed

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests:

You can’t perform that action at this time.