Skip to content

Commit af02fd7

Browse files
committed
OperatorTimerAndSample
1 parent 95e0636 commit af02fd7

11 files changed

+454
-513
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import rx.operators.OperationDelay;
5353
import rx.operators.OperationGroupByUntil;
5454
import rx.operators.OperationGroupJoin;
55-
import rx.operators.OperationInterval;
5655
import rx.operators.OperationJoin;
5756
import rx.operators.OperationMergeDelayError;
5857
import rx.operators.OperationMergeMaxConcurrent;
@@ -62,7 +61,6 @@
6261
import rx.operators.OperationOnExceptionResumeNextViaObservable;
6362
import rx.operators.OperationParallelMerge;
6463
import rx.operators.OperationReplay;
65-
import rx.operators.OperationSample;
6664
import rx.operators.OperationSequenceEqual;
6765
import rx.operators.OperationSkip;
6866
import rx.operators.OperationSkipUntil;
@@ -73,7 +71,6 @@
7371
import rx.operators.OperationTakeWhile;
7472
import rx.operators.OperationThrottleFirst;
7573
import rx.operators.OperationTimeInterval;
76-
import rx.operators.OperationTimer;
7774
import rx.operators.OperationToMap;
7875
import rx.operators.OperationToMultimap;
7976
import rx.operators.OperationUsing;
@@ -112,6 +109,8 @@
112109
import rx.operators.OperatorPivot;
113110
import rx.operators.OperatorRepeat;
114111
import rx.operators.OperatorRetry;
112+
import rx.operators.OperatorSampleWithObservable;
113+
import rx.operators.OperatorSampleWithTime;
115114
import rx.operators.OperatorScan;
116115
import rx.operators.OperatorSerialize;
117116
import rx.operators.OperatorSingle;
@@ -123,6 +122,8 @@
123122
import rx.operators.OperatorTake;
124123
import rx.operators.OperatorTimeout;
125124
import rx.operators.OperatorTimeoutWithSelector;
125+
import rx.operators.OperatorTimerOnce;
126+
import rx.operators.OperatorTimerPeriodically;
126127
import rx.operators.OperatorTimestamp;
127128
import rx.operators.OperatorToObservableFuture;
128129
import rx.operators.OperatorToObservableList;
@@ -1505,7 +1506,7 @@ public final static <T> Observable<T> from(T[] items, Scheduler scheduler) {
15051506
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229027.aspx">MSDN: Observable.Interval</a>
15061507
*/
15071508
public final static Observable<Long> interval(long interval, TimeUnit unit) {
1508-
return create(OperationInterval.interval(interval, unit));
1509+
return create(new OperatorTimerPeriodically(interval, interval, unit, Schedulers.computation()));
15091510
}
15101511

15111512
/**
@@ -1525,7 +1526,7 @@ public final static Observable<Long> interval(long interval, TimeUnit unit) {
15251526
* @see <a href="http://msdn.microsoft.com/en-us/library/hh228911.aspx">MSDN: Observable.Interval</a>
15261527
*/
15271528
public final static Observable<Long> interval(long interval, TimeUnit unit, Scheduler scheduler) {
1528-
return create(OperationInterval.interval(interval, unit, scheduler));
1529+
return create(new OperatorTimerPeriodically(interval, interval, unit, scheduler));
15291530
}
15301531

15311532
/**
@@ -2540,7 +2541,7 @@ public final static Observable<Long> timer(long initialDelay, long period, TimeU
25402541
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229652.aspx">MSDN: Observable.Timer</a>
25412542
*/
25422543
public final static Observable<Long> timer(long initialDelay, long period, TimeUnit unit, Scheduler scheduler) {
2543-
return create(new OperationTimer.TimerPeriodically(initialDelay, period, unit, scheduler));
2544+
return create(new OperatorTimerPeriodically(initialDelay, period, unit, scheduler));
25442545
}
25452546

25462547
/**
@@ -2552,6 +2553,7 @@ public final static Observable<Long> timer(long initialDelay, long period, TimeU
25522553
* the initial delay before emitting a single 0L
25532554
* @param unit
25542555
* time units to use for {@code delay}
2556+
* @return an Observable that emits one item after a specified delay, and then completes
25552557
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#wiki-timer">RxJava wiki: timer()</a>
25562558
*/
25572559
public final static Observable<Long> timer(long delay, TimeUnit unit) {
@@ -2570,10 +2572,12 @@ public final static Observable<Long> timer(long delay, TimeUnit unit) {
25702572
* time units to use for {@code delay}
25712573
* @param scheduler
25722574
* the Scheduler to use for scheduling the item
2575+
* @return Observable that emits one item after a specified delay, on a specified Scheduler, and then
2576+
* completes
25732577
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#wiki-timer">RxJava wiki: timer()</a>
25742578
*/
25752579
public final static Observable<Long> timer(long delay, TimeUnit unit, Scheduler scheduler) {
2576-
return create(new OperationTimer.TimerOnce(delay, unit, scheduler));
2580+
return create(new OperatorTimerOnce(delay, unit, scheduler));
25772581
}
25782582

25792583
/**
@@ -5322,7 +5326,7 @@ public final Observable<T> retry(int retryCount) {
53225326
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#wiki-sample-or-throttlelast">RxJava Wiki: sample()</a>
53235327
*/
53245328
public final Observable<T> sample(long period, TimeUnit unit) {
5325-
return create(OperationSample.sample(this, period, unit));
5329+
return lift(new OperatorSampleWithTime<T>(period, unit, Schedulers.computation()));
53265330
}
53275331

53285332
/**
@@ -5342,7 +5346,7 @@ public final Observable<T> sample(long period, TimeUnit unit) {
53425346
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#wiki-sample-or-throttlelast">RxJava Wiki: sample()</a>
53435347
*/
53445348
public final Observable<T> sample(long period, TimeUnit unit, Scheduler scheduler) {
5345-
return create(OperationSample.sample(this, period, unit, scheduler));
5349+
return lift(new OperatorSampleWithTime<T>(period, unit, scheduler));
53465350
}
53475351

53485352
/**
@@ -5359,7 +5363,7 @@ public final Observable<T> sample(long period, TimeUnit unit, Scheduler schedule
53595363
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#wiki-sample-or-throttlelast">RxJava Wiki: sample()</a>
53605364
*/
53615365
public final <U> Observable<T> sample(Observable<U> sampler) {
5362-
return create(new OperationSample.SampleWithObservable<T, U>(this, sampler));
5366+
return lift(new OperatorSampleWithObservable<T, U>(sampler));
53635367
}
53645368

53655369
/**

rxjava-core/src/main/java/rx/operators/OperationInterval.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)