You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering a possible limitations in triggering some actions whenever something happens. Indeed, the available Events API is only for predefined events and is only related to the ctx object.
To my understanding, it is not possible to create a custom event, and trigger / handle it server side from multiple areas of the code. For instance, I could define an event "CardPlayed" that is notified within a move (every time a player plays a card). Then, if there are one or more handler registered for that event, they will be executed. Otherwise nothing would happen.
Am I missing something?
The text was updated successfully, but these errors were encountered:
Hi, did you find any solution to this issue? I'm having a similar problem and feel like I'm missing something around how to implement custom events in moves. Thanks.
Hello Rosie!
I don't know if there is a better way of doing so provided by the boardgameio framework, btw, I solved the problem by initializing an EventEmitter at the beginning of every server-side stuff in my code (e.g., at the beginning of every move, at the beginning of every onBegin, onEnd, etc.). I create the emitter, subscribe all the possible events listeners to it, and then execute the rest of the move. If within the move there is some piece of code emitting an event (using the created EventEmitter), of course, they would trigger the proper listeners.
Thanks for this amazing framework!
I am encountering a possible limitations in triggering some actions whenever something happens. Indeed, the available Events API is only for predefined events and is only related to the ctx object.
To my understanding, it is not possible to create a custom event, and trigger / handle it server side from multiple areas of the code. For instance, I could define an event "CardPlayed" that is notified within a move (every time a player plays a card). Then, if there are one or more handler registered for that event, they will be executed. Otherwise nothing would happen.
Am I missing something?
The text was updated successfully, but these errors were encountered: