A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://reactivex.io/documentation/operators/interval.html below:

ReactiveX - Interval operator

  1. Operators
  2. Creating
  3. Interval
Interval create an Observable that emits a sequence of integers spaced by a given time interval

The Interval operator returns an Observable that emits an infinite sequence of ascending integers, with a constant interval of time of your choosing between emissions.

See Also Language-Specific Information:

RxGroovy implements this operator as interval. It accepts as its parameters a span of time to wait between emissions and the TimeUnit in which this span is measured.

There is also a version of interval that returns an Observable that emits a single zero after a specified delay, and then emits incrementally increasing numbers periodically thereafter on a specified periodicity. This version of interval was called timer in RxGroovy 1.0.0, but that method has since been deprecated in favor of the one named interval with the same behavior.

interval operates by default on the computation Scheduler. There are also variants that allow you to set the Scheduler by passing one in as a parameter.

RxJava implements this operator as interval. It accepts as its parameters a span of time to wait between emissions and the TimeUnit in which this span is measured.

There is also a version of interval that returns an Observable that emits a single zero after a specified delay, and then emits incrementally increasing numbers periodically thereafter on a specified periodicity. This version of interval was called timer in RxJava 1.0.0, but that method has since been deprecated in favor of the one named interval with the same behavior.

interval operates by default on the computation Scheduler. There are also variants that allow you to set the Scheduler by passing one in as a parameter.

RxJS implements this operator as interval. It accepts as its parameter the number of milliseconds to wait between emissions.

interval operates by default on the timeout Scheduler, or you can optionally pass in a different Scheduler as a second parameter, and interval will operate on that Scheduler instead.

Sample Code
var source = Rx.Observable
    .interval(500 /* ms */)
    .timeInterval()
    .take(3);

var subscription = source.subscribe(
    function (x) {
        console.log('Next: ' + x);
    },
    function (err) {
        console.log('Error: ' + err);
    },
    function () {
        console.log('Completed');
    });
Next: {value: 0, interval: 500}
Next: {value: 1, interval: 500}
Next: {value: 2, interval: 500}
Completed

interval is found in the following distributions:

RxPHP implements this operator as interval.

Returns an Observable that emits an infinite sequence of ascending integers starting at 0, with a constant interval of time of your choosing between emissions.

Sample Code
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/interval/interval.php

\Rx\Observable::interval(1000)
    ->take(5)
    ->subscribe($createStdoutObserver());

   
Next value: 0
Next value: 1
Next value: 2
Next value: 3
Next value: 4
Complete!
    

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4