@Test public void takeLastTimedDelayCompletion() { TestScheduler scheduler = new TestScheduler(); PublishSubject<Object> source = PublishSubject.create(); Observable<Object> result = source.takeLast(1, TimeUnit.SECONDS, scheduler); Observer<Object> o = mock(Observer.class); InOrder inOrder = inOrder(o); result.subscribe(o); source.onNext(1); scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS); source.onNext(2); scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS); source.onNext(3); scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS); source.onNext(4); scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS); source.onNext(5); scheduler.advanceTimeBy(1250, TimeUnit.MILLISECONDS); source.onCompleted(); inOrder.verify(o, times(1)).onCompleted(); verify(o, never()).onNext(any()); verify(o, never()).onError(any(Throwable.class)); }
public static <T> OnSubscribeFunc<T> takeLast(final Observable<? extends T> items, final int count) { return new OnSubscribeFunc<T>() { @Override public Subscription onSubscribe(Observer<? super T> observer) { return new TakeLast<T>(items, count).onSubscribe(observer); } }; }
OperationTakeLast { public static <T> OnSubscribeFunc<T> takeLast(final Observable<? extends T> items, final int count) { return new OnSubscribeFunc<T>() { @Override public Subscription onSubscribe(Observer<? super T> observer) { return new TakeLast<T>(items, count).onSubscribe(observer); } }; } }
OperationTakeLast { public static <T> OnSubscribeFunc<T> takeLast(final Observable<? extends T> items, final int count) { return new OnSubscribeFunc<T>() { @Override public Subscription onSubscribe(Observer<? super T> observer) { return new TakeLast<T>(items, count).onSubscribe(observer); } }; }  }
OperationTakeLast { public static <T> OnSubscribeFunc<T> takeLast(final Observable<? extends T> items, final int count) { return new OnSubscribeFunc<T>() { @Override public Subscription onSubscribe(Observer<? super T> observer) { return new TakeLast<T>(items, count).onSubscribe(observer); } }; }  static OnSubscribeFunc<T> takeLast(final Observable<? extends T> items, final int count); static OnSubscribeFunc<T> takeLast(Observable<? extends T> source, long time, TimeUnit unit, Scheduler scheduler); static OnSubscribeFunc<T> takeLast(Observable<? extends T> source, int count, long time, TimeUnit unit, Scheduler scheduler); }
OperationTakeLast { public static <T> OnSubscribeFunc<T> takeLast(final Observable<? extends T> items, final int count) { return new OnSubscribeFunc<T>() { @Override public Subscription onSubscribe(Observer<? super T> observer) { return new TakeLast<T>(items, count).onSubscribe(observer); } }; }  static OnSubscribeFunc<T> takeLast(final Observable<? extends T> items, final int count); static OnSubscribeFunc<T> takeLast(Observable<? extends T> source, long time, TimeUnit unit, Scheduler scheduler); static OnSubscribeFunc<T> takeLast(Observable<? extends T> source, int count, long time, TimeUnit unit, Scheduler scheduler);  }