-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Deprecate and rename two timer overloads to interval #2975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1225,7 +1225,7 @@ public final static <T> Observable<T> from(T[] array) { | |
* @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a> | ||
*/ | ||
public final static Observable<Long> interval(long interval, TimeUnit unit) { | ||
return interval(interval, unit, Schedulers.computation()); | ||
return interval(interval, interval, unit, Schedulers.computation()); | ||
} | ||
|
||
/** | ||
|
@@ -1248,7 +1248,65 @@ public final static Observable<Long> interval(long interval, TimeUnit unit) { | |
* @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a> | ||
*/ | ||
public final static Observable<Long> interval(long interval, TimeUnit unit, Scheduler scheduler) { | ||
return create(new OnSubscribeTimerPeriodically(interval, interval, unit, scheduler)); | ||
return interval(interval, interval, unit, scheduler); | ||
} | ||
|
||
/** | ||
* Returns an Observable that emits a {@code 0L} after the {@code initialDelay} and ever increasing numbers | ||
* after each {@code period} of time thereafter. | ||
* <p> | ||
* <img width="640" height="200" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timer.p.png" alt=""> | ||
* <dl> | ||
* <dt><b>Backpressure Support:</b></dt> | ||
* <dd>This operator does not support backpressure as it uses time. If the downstream needs a slower rate | ||
* it should slow the timer or use something like {@link #onBackpressureDrop}.</dd> | ||
* <dt><b>Scheduler:</b></dt> | ||
* <dd>{@code timer} operates by default on the {@code computation} {@link Scheduler}.</dd> | ||
* </dl> | ||
* | ||
* @param initialDelay | ||
* the initial delay time to wait before emitting the first value of 0L | ||
* @param period | ||
* the period of time between emissions of the subsequent numbers | ||
* @param unit | ||
* the time unit for both {@code initialDelay} and {@code period} | ||
* @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after | ||
* each {@code period} of time thereafter | ||
* @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a> | ||
* @since 1.0.12 | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public final static Observable<Long> interval(long initialDelay, long period, TimeUnit unit) { | ||
return interval(initialDelay, period, unit, Schedulers.computation()); | ||
} | ||
|
||
/** | ||
* Returns an Observable that emits a {@code 0L} after the {@code initialDelay} and ever increasing numbers | ||
* after each {@code period} of time thereafter, on a specified {@link Scheduler}. | ||
* <p> | ||
* <img width="640" height="200" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timer.ps.png" alt=""> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this change goes through I will change this image but the image URL will still be "...timer.ps.png" so you don't have to change this img tag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't the reinstated javadoc for the deprecated timer method also use the same timer.ps.png image? |
||
* <dl> | ||
* <dt><b>Backpressure Support:</b></dt> | ||
* <dd>This operator does not support backpressure as it uses time. If the downstream needs a slower rate | ||
* it should slow the timer or use something like {@link #onBackpressureDrop}.</dd> | ||
* <dt><b>Scheduler:</b></dt> | ||
* <dd>you specify which {@link Scheduler} this operator will use</dd> | ||
* </dl> | ||
* | ||
* @param initialDelay | ||
* the initial delay time to wait before emitting the first value of 0L | ||
* @param period | ||
* the period of time between emissions of the subsequent numbers | ||
* @param unit | ||
* the time unit for both {@code initialDelay} and {@code period} | ||
* @param scheduler | ||
* the Scheduler on which the waiting happens and items are emitted | ||
* @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after | ||
* each {@code period} of time thereafter, while running on the given Scheduler | ||
* @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a> | ||
* @since 1.0.12 | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public final static Observable<Long> interval(long initialDelay, long period, TimeUnit unit, Scheduler scheduler) { | ||
return create(new OnSubscribeTimerPeriodically(initialDelay, period, unit, scheduler)); | ||
} | ||
|
||
/** | ||
|
@@ -2462,9 +2520,11 @@ public final static <T> Observable<T> switchOnNext(Observable<? extends Observab | |
* @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after | ||
* each {@code period} of time thereafter | ||
* @see <a href="http://reactivex.io/documentation/operators/timer.html">ReactiveX operators documentation: Timer</a> | ||
* @deprecated use {@link #interval(long, long, TimeUnit)} instead | ||
*/ | ||
@Deprecated | ||
public final static Observable<Long> timer(long initialDelay, long period, TimeUnit unit) { | ||
return timer(initialDelay, period, unit, Schedulers.computation()); | ||
return interval(initialDelay, period, unit, Schedulers.computation()); | ||
} | ||
|
||
/** | ||
|
@@ -2491,9 +2551,11 @@ public final static Observable<Long> timer(long initialDelay, long period, TimeU | |
* @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after | ||
* each {@code period} of time thereafter, while running on the given Scheduler | ||
* @see <a href="http://reactivex.io/documentation/operators/timer.html">ReactiveX operators documentation: Timer</a> | ||
* @deprecated use {@link #interval(long, long, TimeUnit, Scheduler)} instead | ||
*/ | ||
@Deprecated | ||
public final static Observable<Long> timer(long initialDelay, long period, TimeUnit unit, Scheduler scheduler) { | ||
return create(new OnSubscribeTimerPeriodically(initialDelay, period, unit, scheduler)); | ||
return interval(initialDelay, period, unit, scheduler); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this change goes through I will change this image but the image URL will still be "...timer.p.png" so you don't have to change this img tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the reinstated javadoc for the deprecated timer method also use the same timer.p.png image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but I don't think that's a big deal. It'd just be another way of highlighting that the behavior of the operator is now available under a more appropriate name.