Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A SimpleEventBus provides the very basic functionality of storing a collection of handlers, and calling event.dispatch() with all of the relevant handlers when appropriate. I wouldn't say that you "set EventBus to listen for events" from the parent widget. The SimpleEventBus doesn't have a concept of a "parent." Instead, you pass around a reference to your SimpleEventBus. Then, <em>any</em> object can "fire an event" with the SimpleEventBus.fireEvent method. There's no hierarchy.</p> <p>Similarly, <em>any</em> object can listen for those events with SimpleEventBus.addHandler(). This is closest to your #4 - addHandler takes a <em>type</em> of event and a handler, so whenever that type of event is passed to <code>fireEvent</code> (by something in your app), that handler will be passed to the event. Note that the <code>Event</code> is what calls the handler, NOT the EventBus! The EventBus just calls event.dispatch(theHandler), and the programmer of the event is responsible for calling the proper function in theHandler. Your #5 is inaccurate, at least for a SimpleEventBus - SimpleEventBus does not inspect the events at all, except to see which handlers to call. It doesn't know about any child widgets or any app logic, and never changes the type of an Event.</p> <p>Your logic about seeing which region was picked would not be appropriate in an EventBus - instead, you would make a handler that does the logic and listens for ClickEvents. Then, that handler could tell the selected region that it was selected directly, or you could create your own RegionSelectionEvent that you could fire along an EventBus, and then all of the regions could be informed that a RegionSelection has occurred, and your logger could get a notification, or your server monitor could get the notification and notify the boss that someone selected a region, or whatever. If you just need to deselect one region and select another, an eventbus is overkill.</p> <p>On the other hand, something like a "resize" event makes a lot of sense, since all of your widgets might need to know about it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload