Morning
I use the SimpleEvent bus to send data from my centralized data editor to Widgets. This works very well, I get one set of new data from the server, the RPC call success method puts it in Eventbus, each widget looks if the data is for it, if so, then it displays it, if not, it does nothing. There is only one data set for each request, and widgets are independent of other data already submitted.
Now I have a Tree widget. In addition, the child nodes of the tree generate these datasets, and these child nodes register with Eventbus to animate the data for their child nodes. Data must be received in a hurry (for obv performance reasons), so I will get several data sets that are placed in Eventbus at the same time (in a for loop). I control only the order in which they are placed (first the root, then the data for the first child ......). How does Eventbus now continue events?
- Does it wait until the completion of the first event, so the first child from the tree has already completed creation and registered with Eventbus to animate the data in order to create its children.
- It processes them simultaneously, so the widget is not even registered in Eventbus.
- Does he mix order?!?!
Modern solutions:
- The best solution I can think of is only to add new events on Eventbus when the previous one is finished. However, I found a method that does this, or if this is standard Eventbus behavior.
- Fire handle the processed processing event when the event was processed by widgets. Yucks ... this leads to a lot of additional code and causes big problems when data is placed on an Eventbus that does not belong to any widget ....
- Register a static variable that is set to true when the request has been processed, and Eventbus waits for this for a long time until it sends the next request to Eventbus (quiet, similar to two, but worse coding style and the same problems)
- All events are processed by the root tree element, which sends them up to the corresponding child element.
Which solution would you prefer and why?
Regards, Stefan
PS: my favorite answer would be that 1. is the standard behavior of Eventbus ^^ PPS: The solution should also work when implementing Web Workers.
source share