Morning,
I'm using the SimpleEvent
bus to send data from my centralized data reviver to the Widgets. This works really fine, I get one set of new Data form the server, the success method of the RPC call puts it on the Eventbus, each widget looks if the data is for it, if yes it 'displays' it, if not, it does nothing.There is only one data set per request and the widgets don't depend on other data being already sent.
Now I have a Tree widget. The child nodes of the Tree are created throw this data sets too, and this child nodes register itself to the Eventbus to revive the data for their child nodes. The data shall be received in on rush (for performance reasons obv), so I will get multiple data sets which are put on the Eventbus at the 'same time' (in a for loop). I only control the order in which they are put there (first the root, then the data for the first child......). How does the Eventbus now proceeds the events?
Current solution approaches:
Which solution would you prefer and why?
Regards, Stefan
PS: my favorite answer would be that 1. is the standard behavior of the Eventbus^^ PPS: The solution should also be working on when introducing Webworkers.
The EventBus#fireEvent
is synchronous. It's by design. You can pass an event to the bus, have handlers possibly modify it, and when execution returns to your method you can check the event; this is used for PlaceChangeRequestEvent
and its setMessage
for instance.
FYI, if a handler throws an exception, it won't prevent other handlers from being executed. The fireEvent
will then wrap the exceptions (plural; several handlers can throw) in an UmbrellaException
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With