Reactive { public static EventRemover addEventCollector( ReactiveValueChangeListener reactiveValueChangeListener) { if (eventCollectors == null) { eventCollectors = JsCollections.set(); } eventCollectors.add(reactiveValueChangeListener); return () -> eventCollectors.delete(reactiveValueChangeListener); } private  Reactive(); static void addFlushListener(FlushListener flushListener); static void addPostFlushListener(FlushListener postFlushListener); static void flush(); static Computation getCurrentComputation(); static void runWithComputation(Computation computation,
            Command command); static EventRemover addEventCollector(
            ReactiveValueChangeListener reactiveValueChangeListener); static void notifyEventCollectors(ReactiveValueChangeEvent event); static Computation runWhenDependenciesChange(Command command); static void reset();  }
@Test public void testCollectEvents() { TestReactiveEventRouter router = new TestReactiveEventRouter(); EventRemover eventRemover = Reactive .addEventCollector(e -> count.incrementAndGet()); Assert.assertEquals(0, count.get()); router.invalidate(); Assert.assertEquals("Event should trigger collector", 1, count.get()); router.invalidate(); Assert.assertEquals("Event should still trigger collector", 2, count.get()); eventRemover.remove(); router.invalidate(); Assert.assertEquals("Event should no longer trigger collector", 2, count.get()); }