ListenerManager { public void listenAndFire(@NotNull ObservableValue<?> src, @NotNull InvalidationListener listener) { listen(src, listener); listener.onInvalidated(); } ListenerManager();  ListenerManager(@NotNull BatchInvoker.Strategy invokeStrategy); void listen(@NotNull ObservableValue<?> src, @NotNull InvalidationListener listener); void listen(@NotNull final ObservableValue<T> src, @NotNull final Receiver<T> receiver); void listenAndFire(@NotNull ObservableValue<?> src, @NotNull InvalidationListener listener); void listenAndFire(@NotNull final ObservableValue<T> src, @NotNull final Receiver<T> receiver); @NotNull CompositeListener listenAll(@NotNull ObservableValue<?>... values); @NotNull CompositeListener listenAll(@NotNull Collection<? extends ObservableValue<?>> values); void release(@NotNull InvalidationListener listener); void release(@NotNull Receiver<?> receiver); void release(@NotNull ObservableValue<?> observable); void release(@NotNull Runnable listenAllRunnable); void releaseAll();  }
@Test public void listenAndFireWorks() throws Exception { ListenerManager listeners = new ListenerManager(); IntListener intListener = new IntListener(); IntValueProperty intProperty = new IntValueProperty(10); listeners.listenAndFire(intProperty, intListener); assertThat(intListener.myInvalidationCount).isEqualTo(1); intProperty.set(20); assertThat(intListener.myInvalidationCount).isEqualTo(2); }
@Test public void receiveAndFireWorks() throws Exception { ListenerManager listeners = new ListenerManager(); IntReceiver intReceiver = new IntReceiver(); IntValueProperty intProperty = new IntValueProperty(10); listeners.listenAndFire(intProperty, intReceiver); assertThat(intReceiver.myInvalidationCount).isEqualTo(1); assertThat(intReceiver.myLastValue).isEqualTo(10); intProperty.set(20); assertThat(intReceiver.myInvalidationCount).isEqualTo(2); assertThat(intReceiver.myLastValue).isEqualTo(20); }