Eventbus event order <p>Morning,</p> <p>I'm using the <code>SimpleEvent</code> 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.</p> <p>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?</p> <ul> <li>Does he wait till the first event is completed, so the first child of the tree already finished creation and register itself to the Eventbus, to revive the data to create it's child's.</li> <li>Does he handle them simultaneous, so a widget isn't even registered to the Eventbus.</li> <li>Does he mix up the order?!?!</li> </ul> <p>Current solution approaches:</p> <ol> <li>The best solution I can think of, is to only put new events on the Eventbus when the previous got completed. However I found a method which does so, or if it is the standard behavior of the Eventbus .</li> <li>Fire a request processing finished event, when a event was processed by a widget. Yucks... this leads to a lot of additional code and causes big problems, when data is put on the Eventbus which doesn't belong to any widget....</li> <li>Register a static variable which is set to true when the request got handled and the Eventbus waits this long till he puts the next request on the Eventbus (Quiet similar to two, but way worse coding style and the same problems)</li> <li>All events are handled by the root tree element, which sends them upwards to the respective child's.</li> </ol> <p>Which solution would you prefer and why?</p> <p>Regards, Stefan</p> <p>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.</p>