@@ -1225,7 +1225,7 @@ public final static <T> Observable<T> from(T[] array) {
12251225 * @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a>
12261226 */
12271227 public final static Observable <Long > interval (long interval , TimeUnit unit ) {
1228- return interval (interval , unit , Schedulers .computation ());
1228+ return interval (interval , interval , unit , Schedulers .computation ());
12291229 }
12301230
12311231 /**
@@ -1248,7 +1248,65 @@ public final static Observable<Long> interval(long interval, TimeUnit unit) {
12481248 * @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a>
12491249 */
12501250 public final static Observable <Long > interval (long interval , TimeUnit unit , Scheduler scheduler ) {
1251- return create (new OnSubscribeTimerPeriodically (interval , interval , unit , scheduler ));
1251+ return interval (interval , interval , unit , scheduler );
1252+ }
1253+
1254+ /**
1255+ * Returns an Observable that emits a {@code 0L} after the {@code initialDelay} and ever increasing numbers
1256+ * after each {@code period} of time thereafter.
1257+ * <p>
1258+ * <img width="640" height="200" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timer.p.png" alt="">
1259+ * <dl>
1260+ * <dt><b>Backpressure Support:</b></dt>
1261+ * <dd>This operator does not support backpressure as it uses time. If the downstream needs a slower rate
1262+ * it should slow the timer or use something like {@link #onBackpressureDrop}.</dd>
1263+ * <dt><b>Scheduler:</b></dt>
1264+ * <dd>{@code timer} operates by default on the {@code computation} {@link Scheduler}.</dd>
1265+ * </dl>
1266+ *
1267+ * @param initialDelay
1268+ * the initial delay time to wait before emitting the first value of 0L
1269+ * @param period
1270+ * the period of time between emissions of the subsequent numbers
1271+ * @param unit
1272+ * the time unit for both {@code initialDelay} and {@code period}
1273+ * @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after
1274+ * each {@code period} of time thereafter
1275+ * @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a>
1276+ * @since 1.0.12
1277+ */
1278+ public final static Observable <Long > interval (long initialDelay , long period , TimeUnit unit ) {
1279+ return interval (initialDelay , period , unit , Schedulers .computation ());
1280+ }
1281+
1282+ /**
1283+ * Returns an Observable that emits a {@code 0L} after the {@code initialDelay} and ever increasing numbers
1284+ * after each {@code period} of time thereafter, on a specified {@link Scheduler}.
1285+ * <p>
1286+ * <img width="640" height="200" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/timer.ps.png" alt="">
1287+ * <dl>
1288+ * <dt><b>Backpressure Support:</b></dt>
1289+ * <dd>This operator does not support backpressure as it uses time. If the downstream needs a slower rate
1290+ * it should slow the timer or use something like {@link #onBackpressureDrop}.</dd>
1291+ * <dt><b>Scheduler:</b></dt>
1292+ * <dd>you specify which {@link Scheduler} this operator will use</dd>
1293+ * </dl>
1294+ *
1295+ * @param initialDelay
1296+ * the initial delay time to wait before emitting the first value of 0L
1297+ * @param period
1298+ * the period of time between emissions of the subsequent numbers
1299+ * @param unit
1300+ * the time unit for both {@code initialDelay} and {@code period}
1301+ * @param scheduler
1302+ * the Scheduler on which the waiting happens and items are emitted
1303+ * @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after
1304+ * each {@code period} of time thereafter, while running on the given Scheduler
1305+ * @see <a href="http://reactivex.io/documentation/operators/interval.html">ReactiveX operators documentation: Interval</a>
1306+ * @since 1.0.12
1307+ */
1308+ public final static Observable <Long > interval (long initialDelay , long period , TimeUnit unit , Scheduler scheduler ) {
1309+ return create (new OnSubscribeTimerPeriodically (initialDelay , period , unit , scheduler ));
12521310 }
12531311
12541312 /**
@@ -2462,9 +2520,11 @@ public final static <T> Observable<T> switchOnNext(Observable<? extends Observab
24622520 * @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after
24632521 * each {@code period} of time thereafter
24642522 * @see <a href="http://reactivex.io/documentation/operators/timer.html">ReactiveX operators documentation: Timer</a>
2523+ * @deprecated use {@link #interval(long, long, TimeUnit)} instead
24652524 */
2525+ @ Deprecated
24662526 public final static Observable <Long > timer (long initialDelay , long period , TimeUnit unit ) {
2467- return timer (initialDelay , period , unit , Schedulers .computation ());
2527+ return interval (initialDelay , period , unit , Schedulers .computation ());
24682528 }
24692529
24702530 /**
@@ -2491,9 +2551,11 @@ public final static Observable<Long> timer(long initialDelay, long period, TimeU
24912551 * @return an Observable that emits a 0L after the {@code initialDelay} and ever increasing numbers after
24922552 * each {@code period} of time thereafter, while running on the given Scheduler
24932553 * @see <a href="http://reactivex.io/documentation/operators/timer.html">ReactiveX operators documentation: Timer</a>
2554+ * @deprecated use {@link #interval(long, long, TimeUnit, Scheduler)} instead
24942555 */
2556+ @ Deprecated
24952557 public final static Observable <Long > timer (long initialDelay , long period , TimeUnit unit , Scheduler scheduler ) {
2496- return create ( new OnSubscribeTimerPeriodically ( initialDelay , period , unit , scheduler ) );
2558+ return interval ( initialDelay , period , unit , scheduler );
24972559 }
24982560
24992561 /**
0 commit comments