Skip to content

Latest commit

 

History

History
62 lines (48 loc) · 2.43 KB

pausable.md

File metadata and controls

62 lines (48 loc) · 2.43 KB

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: