@Test(expected = TestException.class) public void testMostRecentWithException() { Subject<String, String> s = PublishSubject.create(); Iterator<String> it = mostRecent(s, "default").iterator(); assertTrue(it.hasNext()); assertEquals("default", it.next()); assertEquals("default", it.next()); s.onError(new TestException()); assertTrue(it.hasNext()); it.next(); }
public static <T> Iterable<T> mostRecent(final Observable<? extends T> source, final T initialValue) { return new Iterable<T>() { @Override public Iterator<T> iterator() { MostRecentObserver<T> mostRecentObserver = new MostRecentObserver<T>(initialValue); final MostRecentIterator<T> nextIterator = new MostRecentIterator<T>(mostRecentObserver); source.subscribe(mostRecentObserver); return nextIterator; } }; }
OperationMostRecent { public static <T> Iterable<T> mostRecent(final Observable<? extends T> source, final T initialValue) { return new Iterable<T>() { @Override public Iterator<T> iterator() { MostRecentObserver<T> mostRecentObserver = new MostRecentObserver<T>(initialValue); final MostRecentIterator<T> nextIterator = new MostRecentIterator<T>(mostRecentObserver); source.subscribe(mostRecentObserver); return nextIterator; } }; } }
OperationMostRecent { public static <T> Iterable<T> mostRecent(final Observable<? extends T> source, final T initialValue) { return new Iterable<T>() { @Override public Iterator<T> iterator() { MostRecentObserver<T> mostRecentObserver = new MostRecentObserver<T>(initialValue); final MostRecentIterator<T> nextIterator = new MostRecentIterator<T>(mostRecentObserver); source.subscribe(mostRecentObserver); return nextIterator; } }; }  }
OperationMostRecent { public static <T> Iterable<T> mostRecent(final Observable<? extends T> source, final T initialValue) { return new Iterable<T>() { @Override public Iterator<T> iterator() { MostRecentObserver<T> mostRecentObserver = new MostRecentObserver<T>(initialValue); final MostRecentIterator<T> nextIterator = new MostRecentIterator<T>(mostRecentObserver); source.subscribe(mostRecentObserver); return nextIterator; } }; }  static Iterable<T> mostRecent(final Observable<? extends T> source, final T initialValue); }
OperationMostRecent { public static <T> Iterable<T> mostRecent(final Observable<? extends T> source, final T initialValue) { return new Iterable<T>() { @Override public Iterator<T> iterator() { MostRecentObserver<T> mostRecentObserver = new MostRecentObserver<T>(initialValue); final MostRecentIterator<T> nextIterator = new MostRecentIterator<T>(mostRecentObserver); source.subscribe(mostRecentObserver); return nextIterator; } }; }  static Iterable<T> mostRecent(final Observable<? extends T> source, final T initialValue);  }