Skip to content

Commit 4deca78

Browse files
add timer methods in Observable.java
1 parent 8b039f5 commit 4deca78

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import rx.operators.OperationThrottleFirst;
9292
import rx.operators.OperationTimeInterval;
9393
import rx.operators.OperationTimeout;
94+
import rx.operators.OperationTimer;
9495
import rx.operators.OperationTimestamp;
9596
import rx.operators.OperationToMap;
9697
import rx.operators.OperationToMultimap;
@@ -1990,6 +1991,33 @@ public static Observable<Long> interval(long interval, TimeUnit unit, Scheduler
19901991
return create(OperationInterval.interval(interval, unit, scheduler));
19911992
}
19921993

1994+
/**
1995+
* Emits one item after a given delay, and then completes.
1996+
*
1997+
* @param interval
1998+
* interval size in time units
1999+
* @param unit
2000+
* time units to use for the interval size
2001+
*/
2002+
public static Observable<Void> timer(long interval, TimeUnit unit) {
2003+
return create(OperationTimer.timer(interval, unit));
2004+
}
2005+
2006+
/**
2007+
* Emits one item after a given delay, and then completes.
2008+
*
2009+
* @param interval
2010+
* interval size in time units
2011+
* @param unit
2012+
* time units to use for the interval size
2013+
* @param scheduler
2014+
* the scheduler to use for scheduling the item
2015+
*/
2016+
public static Observable<Void> timer(long interval, TimeUnit unit,
2017+
Scheduler scheduler) {
2018+
return create(OperationTimer.timer(interval, unit, scheduler));
2019+
}
2020+
19932021
/**
19942022
* Drops items emitted by an Observable that are followed by newer items
19952023
* before a timeout value expires. The timer resets on each emission.

0 commit comments

Comments
 (0)