@Test(timeout = 60000) public void testDispose() throws Exception { ListenerWithSub l = holderRule.addAListener(); holderRule.getHolder().dispose(); assertThat("On complete not called on dispose.", l.listener.getOnCompletedCount(), is(1)); assertThat("Listener not unsubscribed on dispose.", l.subscription.isUnsubscribed(), is(true)); assertThat("Listener not removed on dispose.", holderRule.getHolder().getAllListeners(), not(contains(l.listener))); }
public void dispose() { ListenerInvocationException exception = null; for (ListenerHolder<T> listener : listeners) { try { listener.onCompleted(); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } if (null != exception) { exception.finish(); throw exception; } }
ListenersHolder implements EventSource<T>, EventPublisher { public void dispose() { ListenerInvocationException exception = null; for (ListenerHolder<T> listener : listeners) { try { listener.onCompleted(); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } if (null != exception) { exception.finish(); throw exception; } } }
ListenersHolder implements EventSource<T>, EventPublisher { public void dispose() { ListenerInvocationException exception = null; for (ListenerHolder<T> listener : listeners) { try { listener.onCompleted(); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } if (null != exception) { exception.finish(); throw exception; } } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); }
ListenersHolder implements EventSource<T>, EventPublisher { public void dispose() { ListenerInvocationException exception = null; for (ListenerHolder<T> listener : listeners) { try { listener.onCompleted(); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } if (null != exception) { exception.finish(); throw exception; } } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); @Override Subscription subscribe(final T listener); @Override boolean publishingEnabled(); void dispose(); void invokeListeners(Action1<T> invocationAction); void invokeListeners(Action3<T, Long, TimeUnit> invocationAction, long duration, TimeUnit timeUnit); void invokeListeners(Action4<T, Long, TimeUnit, Throwable> invocationAction, long duration,
                                TimeUnit timeUnit, Throwable throwable); void invokeListeners(Action4<T, Long, TimeUnit, A> invocationAction, long duration,
                                    TimeUnit timeUnit, A arg); void invokeListeners(Action5<T, Long, TimeUnit, Throwable, A> invocationAction, long duration,
                                    TimeUnit timeUnit, Throwable throwable, A arg); void invokeListeners(Action2<T, A> invocationAction, A arg); void invokeListeners(Action3<T, Throwable, A> invocationAction, Throwable throwable, A arg); ListenersHolder<T> copy(); void subscribeAllTo(EventSource<T> lazySource); }
ListenersHolder implements EventSource<T>, EventPublisher { public void dispose() { ListenerInvocationException exception = null; for (ListenerHolder<T> listener : listeners) { try { listener.onCompleted(); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } if (null != exception) { exception.finish(); throw exception; } } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); @Override Subscription subscribe(final T listener); @Override boolean publishingEnabled(); void dispose(); void invokeListeners(Action1<T> invocationAction); void invokeListeners(Action3<T, Long, TimeUnit> invocationAction, long duration, TimeUnit timeUnit); void invokeListeners(Action4<T, Long, TimeUnit, Throwable> invocationAction, long duration,
                                TimeUnit timeUnit, Throwable throwable); void invokeListeners(Action4<T, Long, TimeUnit, A> invocationAction, long duration,
                                    TimeUnit timeUnit, A arg); void invokeListeners(Action5<T, Long, TimeUnit, Throwable, A> invocationAction, long duration,
                                    TimeUnit timeUnit, Throwable throwable, A arg); void invokeListeners(Action2<T, A> invocationAction, A arg); void invokeListeners(Action3<T, Throwable, A> invocationAction, Throwable throwable, A arg); ListenersHolder<T> copy(); void subscribeAllTo(EventSource<T> lazySource);  }