@Test public void testOn() { emitter.on(testEventName, listener); Assert.assertEquals(0, store.size()); emitter.emit(testEventName, event1); Assert.assertEquals(1, store.size()); Assert.assertSame(event1, store.get(0)); emitter.emit(testEventName, event2); Assert.assertEquals(2, store.size()); Assert.assertSame(event1, store.get(0)); Assert.assertSame(event2, store.get(1)); }
public Emitter on(String event, Listener fn) { ConcurrentLinkedQueue<Listener> callbacks = this.callbacks.get(event); if (callbacks == null) { callbacks = new ConcurrentLinkedQueue<Listener>(); ConcurrentLinkedQueue<Listener> _callbacks = this.callbacks.putIfAbsent(event, callbacks); if (_callbacks != null) { callbacks = _callbacks; } } callbacks.add(fn); return this; }
Emitter { public Emitter on(String event, Listener fn) { ConcurrentLinkedQueue<Listener> callbacks = this.callbacks.get(event); if (callbacks == null) { callbacks = new ConcurrentLinkedQueue<Listener>(); ConcurrentLinkedQueue<Listener> _callbacks = this.callbacks.putIfAbsent(event, callbacks); if (_callbacks != null) { callbacks = _callbacks; } } callbacks.add(fn); return this; } }
Emitter { public Emitter on(String event, Listener fn) { ConcurrentLinkedQueue<Listener> callbacks = this.callbacks.get(event); if (callbacks == null) { callbacks = new ConcurrentLinkedQueue<Listener>(); ConcurrentLinkedQueue<Listener> _callbacks = this.callbacks.putIfAbsent(event, callbacks); if (_callbacks != null) { callbacks = _callbacks; } } callbacks.add(fn); return this; }  }
Emitter { public Emitter on(String event, Listener fn) { ConcurrentLinkedQueue<Listener> callbacks = this.callbacks.get(event); if (callbacks == null) { callbacks = new ConcurrentLinkedQueue<Listener>(); ConcurrentLinkedQueue<Listener> _callbacks = this.callbacks.putIfAbsent(event, callbacks); if (_callbacks != null) { callbacks = _callbacks; } } callbacks.add(fn); return this; }  Emitter on(String event, Listener fn); Emitter once(final String event, final Listener<T> fn); Emitter off(); Emitter off(String event); Emitter off(String event, Listener fn); Future emit(String event, T... args); List<Listener> listeners(String event); boolean hasListeners(String event); }
Emitter { public Emitter on(String event, Listener fn) { ConcurrentLinkedQueue<Listener> callbacks = this.callbacks.get(event); if (callbacks == null) { callbacks = new ConcurrentLinkedQueue<Listener>(); ConcurrentLinkedQueue<Listener> _callbacks = this.callbacks.putIfAbsent(event, callbacks); if (_callbacks != null) { callbacks = _callbacks; } } callbacks.add(fn); return this; }  Emitter on(String event, Listener fn); Emitter once(final String event, final Listener<T> fn); Emitter off(); Emitter off(String event); Emitter off(String event, Listener fn); Future emit(String event, T... args); List<Listener> listeners(String event); boolean hasListeners(String event);  }