@Test public void testTakeLastWithNegativeCount() { Observable<String> w = Observable.from("one"); Observable<String> take = Observable.create(takeLast(w, -1)); @SuppressWarnings("unchecked") Observer<String> observer = mock(Observer.class); take.subscribe(observer); verify(observer, never()).onNext("one"); verify(observer, times(1)).onError( any(IndexOutOfBoundsException.class)); verify(observer, never()).onCompleted(); }
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);  }