Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Latest commit

 

History

History
60 lines (46 loc) · 2.12 KB

while.md

File metadata and controls

60 lines (46 loc) · 2.12 KB

Rx.Observable.while(condition, source)

Rx.Observable.whileDo(condition, source) DEPRECATED

Repeats source as long as condition holds emulating a while loop. There is an alias for this method called 'whileDo' for browsers <IE9.

Arguments

  1. condition (Function): The condition which determines if the source will be repeated.
  2. source (Observable): The observable sequence that will be run if the condition function returns true.

Returns

(Observable): An observable sequence which is repeated as long as the condition holds.

Example

var i = 0;

// Repeat until condition no longer holds
var source = Rx.Observable.while(
    function () { return i++ < 3 },
    Rx.Observable.return(42)
);

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

// => Next: 42
// => Next: 42
// => Next: 42
// => Completed

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: