I have a class PricingModel which needs to listen for bus events coming from 
a variety of UI elements. (The user will make choices, e.g. from drop down 
list, or checkboxes, etc. and I need to recompute a price plan as they 
modify their choices.) My PricingModel in turn needs to emit updated 
information for various parts of the UI to pick up. I know I want to use the 
GWT EventBus rather than amass spaghetti code of callback functions.

However, I've failed to turn up worthy code examples that employ 
SimpleEventBus. So I'm trying to understand what is intended from the 
javadocs for 
SimpleEventBus<http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/event/shared/SimpleEventBus.html>,
 
GwtEvent<http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/event/shared/GwtEvent.html>,
 
and 
EventHandler<http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/event/shared/EventHandler.html>
. 

I started by creating two classes, OnChangePlanHandler, and OnChangePlan 
extends GwtEvent<OnChangePlanHandler>. I see where my 
OnChangePlan.dispatch(OnChangePlanHander 
handler) will be invoked.

Q1) I presume inside my dispatch() function I am probably supposed to call 
appropriate functions that I create in my OnChangePlanHander class?

Q2) What do I return for OnChangePlan.getAssociatedType()? Do I need to 
create a subclass of GwtEvent.Type<OnChangePlanHandler> too? When would I 
ever create an instance of this subclass? Will I ever create more than one 
instance of this subclass? (i.e. where should I be storing this instance?) 
It looks like I might have just one such instance declared statically 
somewhere to return it from OnChangePlan.getAssociatedType(). Right?

Q3) The javadocs for SimpleEventBus.addHandler() says it should *rarely* be 
called directly. (??)  The alternative code snippet offered in the javadocs 
lacks enough context for me; I don't yet understand the entire scheme of how 
these classes are intended to work together.

In all, I'm looking to understand how these classes are meant to work 
together. I can write up a full example for others if I can collect the bits 
of knowledge.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/M1V3MUhKQWhaQ3NK.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to