Question

I want to be able to listen to all events dispatched on the Event Bus, regardless of type. How can I do this?

Was it helpful?

Solution

Taking a cue from Thomas's suggestion, here is a sample solution:

    public class MyEventBus extends SimpleEventBus {

    @Override
    public void fireEvent( GwtEvent<?> event ) {
        trackEvent( "Event Fired", event.getClass().toString() );
        super.fireEvent( event );
    }

    public native void trackEvent( String category, String action ) /*-{
        $wnd._gaq.push([ '_trackEvent', category, action ]);
    }-*/;
}

OTHER TIPS

SimpleEventBus doesn't let you do this, but you could easily wrap or extend it and override fireEvent et al. to catch all dispatched events.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top