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
- Range
- Repeat
- Timer
- Introduction to Rx: Interval
- 101 Rx Samples: Observing the Passing of Time
- 101 Rx Samples: Interval — Simple
- ad-hockery: Simple Background Polling with RxJava
Language-Specific Information
RxGroovy interval

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.
- Javadoc:
interval(long,TimeUnit)
- Javadoc:
interval(long,TimeUnit,Scheduler)

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.
- Javadoc:
interval(long,long,TimeUnit)
- Javadoc:
interval(long,long,TimeUnit,Scheduler)
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 1․x interval

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.
- Javadoc:
interval(long,TimeUnit)
- Javadoc:
interval(long,TimeUnit,Scheduler)

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.
- Javadoc:
interval(long,long,TimeUnit)
- Javadoc:
interval(long,long,TimeUnit,Scheduler)
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 interval

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:
rx.lite.js
rx.lite.compat.js
-
rx.timejs
(requiresrx.js
orrx.compat.js
)
RxPHP interval
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!
© ReactiveX contributors
Licensed under the Apache License 2.0.
http://reactivex.io/documentation/operators/interval.html