This repository has been archived by the owner. It is now read-only.
Permalink
63 lines (48 sloc) 2.43 KB

This is RxJS v 4. Find the latest version here

Rx.Observable.prototype.pausable(pauser)

Pauses the underlying observable sequence based upon the observable sequence which yields true/false. Note that this only works on hot observables.

Arguments

  1. pauser (Observable): The observable sequence used to pause the underlying sequence.

Returns

(Observable): The observable sequence which is paused based upon the pauser.

Example

var pauser = new Rx.Subject();
var source = Rx.Observable.fromEvent(document, 'mousemove').pausable(pauser);

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

// To begin the flow
pauser.onNext(true); // or source.resume();

// To pause the flow at any point
pauser.onNext(false);  // or source.pause();

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: