public static Subscription subscribeJsType(final String eventType, final JsTypeEventObserver<?> callback) { WindowEventObservers.createOrGet().add(eventType, callback); return new Subscription() { @Override public void remove() { // TODO can't unsubscribe per module atm. } }; }
public static WindowEventObservers createOrGet() { if (!windowEventObserversDefined()) { setWindowEventObservers(new WindowEventObservers()); } return getWindowEventObservers(); }
public static void consumeEventFromMessage(final Message message) { final String beanType = message.get(String.class, CDIProtocol.BeanType); final Object beanRef = message.get(Object.class, CDIProtocol.BeanReference); final Set<String> firedBeanTypes = new HashSet<>(); final Deque<String> beanTypeQueue = new LinkedList<>(); beanTypeQueue.addLast(beanType); firedBeanTypes.add(beanType); while (!beanTypeQueue.isEmpty()) { final String curType = beanTypeQueue.poll(); WindowEventObservers.createOrGet().fireEvent(curType, beanRef); _fireEvent(curType, message); if (lookupTable.containsKey(curType)) { for (final String superType : lookupTable.get(curType)) { if (!firedBeanTypes.contains(superType)) { beanTypeQueue.addLast(superType); firedBeanTypes.add(superType); } } } } }
@SuppressWarnings({ "rawtypes", "unchecked" }) public void fireEvent(final String eventType, final Object evt) { for (final JsTypeEventObserver observer : get(eventType)) { observer.onEvent(evt); } }
public static void consumeEventFromMessage(final Message message) { final String beanType = message.get(String.class, CDIProtocol.BeanType); final Object beanRef = message.get(Object.class, CDIProtocol.BeanReference); final Set<String> firedBeanTypes = new HashSet<>(); final Deque<String> beanTypeQueue = new LinkedList<>(); beanTypeQueue.addLast(beanType); firedBeanTypes.add(beanType); while (!beanTypeQueue.isEmpty()) { final String curType = beanTypeQueue.poll(); WindowEventObservers.createOrGet().fireEvent(curType, beanRef); _fireEvent(curType, message); if (lookupTable.containsKey(curType)) { for (final String superType : lookupTable.get(curType)) { if (!firedBeanTypes.contains(superType)) { beanTypeQueue.addLast(superType); firedBeanTypes.add(superType); } } } } }
public static Subscription subscribeJsType(final String eventType, final JsTypeEventObserver<?> callback) { WindowEventObservers.createOrGet().add(eventType, callback); return new Subscription() { @Override public void remove() { // TODO can't unsubscribe per module atm. } }; }