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

Latest commit

 

History

History
68 lines (55 loc) · 2.61 KB

repeatwhen.md

File metadata and controls

68 lines (55 loc) · 2.61 KB

Rx.Observable.prototype.repeatWhen(notificationHandler)

Returns an Observable that emits the same values as the source Observable with the exception of an onCompleted. An onCompleted notification from the source will result in the emission of a void item to the Observable provided as an argument to the notificationHandler function. If that Observable calls onComplete or onError then repeatWhen will call onCompleted or onError on the child subscription. Otherwise, this Observable will resubscribe to the source observable.

Arguments

  1. notificationHandler: Function - receives an Observable of notifications with which a user can complete or error, aborting the repeat.

Returns

Observable: Observable modified with repeat logic

Example: Delayed repeat

var source = Rx.Observable.just(42)
  .repeatWhen(function(notifications) {
    return notifications.scan(
      function (acc, x, i) { return acc + i; }, 0)
    .delay(200)
    .takeWhile(function (count) {
      return count < 1;
    });
  });

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

// => Next: 42
// 200 ms pass
// => Next: 42
// 200 ms pass
// => Completed

Location

File:

Dist:

Prerequisites:

  • None

NPM Packages:

NuGet Packages:

Unit Tests: