Open Zomis opened 2 years ago
Actually, all event-related things can be SharedFlow
instead of the current event-listeners (not to mention the feature system).
However, there are currently some separate branches and stashed changes in my working repository. Changing these things would cause lots of potential merge conflicts, but as all the changes (the diffs) are stored, I think it's worth it to just keep going and perform it. Besides, some branches contain work on the Vue client which will not be affected.
This would be a good replacement for #41
Actually, important thing to remember is that SharedFlows are asynchronous, so only time-irrelevant events should be converted to SharedFlows.
For example, pre-move events that allows listeners to add pre-randomised data are not possible with a SharedFlow, because they need to have the opportunity to change the state before the code moves on.
Things that needs to have the opportunity to change state before code moves on can use a Deferred
. This has now been introduced for PreMove
and PreSetup
.
However, currently these are being marked as completed after all GameListeners has handled the events. So if this would change to SharedFlows, it would be a lot more complicated to mark something as completed.
Kotlin SharedFlow can replace the communication between coroutines in
GameFlowImpl
instead of channels. Even more so, it should also make it possible to add more different listeners and separate the concerns even better.