-
Does anyone have any good examples on how you'd implement a signal/event/observer pattern in Ebiten and Go? Examples of such patterns: https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could do this with message passing - a message can be anything and fulfill a certain interface. You register listeners with some global object, and then send messages to those registered listeners. Those listeners can be any kind of object. Here's a repo that does that: https://github.com/SolarLune/messages You could also just do this with interfaces directly, as objects can be checked to see if they implement an interface, which would indicate they subscribe to the desired message type. |
Beta Was this translation helpful? Give feedback.
You could do this with message passing - a message can be anything and fulfill a certain interface. You register listeners with some global object, and then send messages to those registered listeners. Those listeners can be any kind of object.
Here's a repo that does that: https://github.com/SolarLune/messages
You could also just do this with interfaces directly, as objects can be checked to see if they implement an interface, which would indicate they subscribe to the desired message type.