Its not a stupid question. Other people also stumbled upon this.

On your EventBus a PlaceChangeEvent is fired when you want to switch 
places. The ActivityManager listens for this event and calls 
Activity.start() on the new activity. That means Activity.start() is called 
inside an event dispatch and while the SimpleEventBus dispatches events all 
newly added handlers are queued until the SimpleEventBus is done. When all 
events are done SimpleEventBus merges the queue of newly added handlers 
into the list of all handlers. Then these newly added handlers can be 
considered "active" and they will start receiving events.

So when you add handlers to the SimpleEventBus inside Activity.start() 
these handlers are active AFTER Activity.start() returns and all other 
events have been dispatched by the SimpleEventBus.

When you use a deferred command all code inside that command is delayed 
until the regular code completes. In that case your command will be 
executed after Activity.start() has returned and the event dispatch of 
PlaceChangeEvent is done. Thus the handlers are active now and the code 
inside your command "suddenly" works.


-- J.


-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to