Skip to content

Commit 00b7116

Browse files
committed
Add timer variants to RxScala
1 parent 025d3c4 commit 00b7116

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,6 +3818,32 @@ object Observable {
38183818
toScalaObservable[java.lang.Long](rx.Observable.timer(initialDelay.toNanos, period.toNanos, duration.NANOSECONDS, scheduler)).map(_.longValue())
38193819
}
38203820

3821+
/**
3822+
* Returns an Observable that emits `0L` after a specified delay, and then completes.
3823+
*
3824+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/timer.png">
3825+
*
3826+
* @param delay the initial delay before emitting a single `0L`
3827+
* @return Observable that emits `0L` after a specified delay, and then completes
3828+
*/
3829+
def timer(delay: Duration): Observable[Long] = {
3830+
toScalaObservable[java.lang.Long](rx.Observable.timer(delay.length, delay.unit)).map(_.longValue())
3831+
}
3832+
3833+
/**
3834+
* Returns an Observable that emits `0L` after a specified delay, on a specified Scheduler, and then
3835+
* completes.
3836+
*
3837+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/timer.s.png">
3838+
*
3839+
* @param delay the initial delay before emitting a single `0L`
3840+
* @param scheduler the Scheduler to use for scheduling the item
3841+
* @return Observable that emits `0L` after a specified delay, on a specified Scheduler, and then completes
3842+
*/
3843+
def timer(delay: Duration, scheduler: Scheduler): Observable[Long] = {
3844+
toScalaObservable[java.lang.Long](rx.Observable.timer(delay.length, delay.unit, scheduler)).map(_.longValue())
3845+
}
3846+
38213847
/**
38223848
* Constructs an Observable that creates a dependent resource object.
38233849
* <p>

0 commit comments

Comments
 (0)