Registering events handlers

To catch an event, EventHandler must be registered in EventBus:

EventHandler handler = new EventHandler() {
    public void onEvent(Event event) {


eventBus.addHandler(SampleEvent.class, handler);

The other way to register a handler is by using annotations. Event consumer class must contain the method with a single parameter, and its type must be equal to expected event type. 

public static class SampleConsumer {

	public void onCatchSomeNiceEvent(SampleEvent event) {

	public void onEvent01(ImportantEvent event) {

The instance of class must be registered in Eventbus:


Once this is in place, EventBus will be added as the event handler for two different events.