-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace EventDispatcher with an off the shelf solution #1827
Comments
Should also replace public void updateAfterSelection() {
MapTool.getFrame().getSelectionPanel().reset();
MapTool.getFrame().getImpersonatePanel().resetIfNotImpersonating();
HTMLFrameFactory.selectedListChanged();
repaintDebouncer.dispatch();
} ModelChangeEvent which is fired off by
Used by
(yeah its a lot) |
Related: the classes |
|
Why this particular Off the Shelf solution? |
Because its simple(ish), works well, doesn't require external configuration to set up, there is enough documentation on it, and will be enough for out needs. If you have an alternate suggestion that fits the above, I am willing to consider it. |
@bubblobill looking at that it doesn't really seem to fit what we need. From the reading I have done you can use RxJava to have a such an EventBus like set up but its more complicated and you then don't really gain much for the extra complication. |
Is this a chance to rework how updates go through the full stack? There's so much explicit dependency coded into the classes, e.g. ZoneRenderer.modelChanged>MapTool.updateTokenTree, which updates two components explicitly
and ServerMethodHandler calling methods straight into the UI, then broadcasting
One would have to really untangle all that explicit dependency for a cleaner, clearly separated area of responsibility approach. That would also open up a future for a headless server which seems impossible now. |
At the moment, the initiative panel already listens for Zone Activations and Token Change events via ModelChangeListener. I believe the Author sprinkled in the updateTokenTree() every change they found wasn't updating the tree properly (and I know some of the not updated properly were due to threading issues). Hopefully once I have addressed the above the whole Really it would be nice to redo all of the InitiativePanel but where will I find the time :)
Eventually yes, but for the first part just the above change though is big enough. Once that is done the next bit would be untangling things more in how the clients/server/UI interact. |
I can take a look at replacing the One more thing in addition to what's already been mentioned here: it might be beneficial to also use an event bus instead of
|
You've got my vote. |
It's got my vote too :) |
Awesome, glad we're all thinking the same thing! |
Just discovered this little nugget: google/guava#1630 (comment)
|
So recommendation seem so to be to use DI with rxjava. Last time I looked at java DI frameworks I dagger2 looked best to me. |
I do believe the event bus model is still the most appealing for us, particularly for this reason articulated above:
It's just that the Guava devs have decided the model isn't so good and would rather use something else. Whatever we move to in the future, we should still be aiming to use the event bus model inside MapTool. For now, Guava's |
I agree that some kind of bus seems to suit us. But we could also do this with rxjava as written in here or here. (Stolen from guava eventbus javadoc). I also can live with keeping guava eventbus. We could also use Edit: otto is abandoned too. |
I'll just close this off as there should not be any change in behaviour. Bugs can be opened as they surface. |
Is your feature request related to a problem? Please describe.
The EventDispatcher class should be replaced with an off the shelf event dispatcher.
Describe the solution you'd like
Replace EventDispatcher with Google EventBus.
Additional context
This required replacing current
Used in
MapTool.setCampaign() should be changed to dispatch a new campaign event, replacing the below code
Eventually this can be expanded to include other events things like advancing initiative etc.
The text was updated successfully, but these errors were encountered: