{ @Subscribe public void recordCustomerChange(ChangeEvent e) { recordChange(e.getChange()); } } // somewhere during initialisation eventBus.register(new EventBusChangeRecorder()); // much later public void changeCustomer() { ChangeEvent event = getChangeEvent(); eventBus.post(event); } guava/EventBus // Class is typically registered by the container. class EventBusChangeRecorder { @Subscribe public void recordCustomerChange(ChangeEvent e) { recordChange(e.getChange()); } } // somewhere during initialisation eventBus.register(new EventBusChangeRecorder()); // much later public void changeCustomer() { ChangeEvent event = getChangeEvent(); eventBus.post(event); }
void notify(Message message); } // Publishing an Event Watchers.of(PushWatcher.class).notify(message); // Subscribing to an Event public class MyFragment extends Fragment implement PushWatcher { public void notify(Message message) { } public void onStart() { Watchers.bind(this); } } Watcher
void notify(Message message); } // Publishing an Event Watchers.of(PushWatcher.class).notify(message); // Subscribing to an Event public class MyFragment extends Fragment implement PushWatcher { public void notify(Message message) { } public void onStart() { Watchers.bind(this); } } Watcher // Define an Event public interface PushWatcher extents Watchers.Watcher { void notify(Message message); } // Publishing an Event Watchers.of(PushWatcher.class).notify(message); // Subscribing to an Event public class MyFragment extends Fragment implement PushWatcher { public void notify(Message message) { } public void onStart() { Watchers.bind(this); } }
void notify(Message message); } // Publishing an Event Watchers.of(PushWatcher.class).notify(message); // Subscribing to an Event public class MyFragment extends Fragment implement PushWatcher { public void notify(Message message) { } public void onStart() { Watchers.bind(this); } } ᔄࣳਞق & ᯿
void notify(Message message); } // Publishing an Event Watchers.of(PushWatcher.class).notify(message); // Subscribing to an Event public class MyFragment extends Fragment implement PushWatcher { public void notify(Message message) { } public void onStart() { Watchers.bind(this); } } ᔄࣳਞق & ᯿ // Define an Event public interface PushWatcher extents Watchers.Watcher { void notify(Message message); } // Publishing an Event Watchers.of(PushWatcher.class).notify(message); // Subscribing to an Event public class MyFragment extends Fragment implement PushWatcher { public void notify(Message message) { } public void onStart() { Watchers.bind(this); } }