If you try to publish an Event that no handler is listening the program panic since no event bus is found.
How to Reproduce
Create a new event and try to publish to it.
type EnemyKilled struct {
EnemyID int
}
var EnemyKilledEvent = events.NewEventType[*EnemyKilled]()
func TestEvents(t *testing.T) {
w := donburi.NewWorld()
EnemyKilledEvent.Publish(w, &EnemyKilled{EnemyID: 1})
}
Problem
It makes sense to only initialize a bus if there is a handler to react to it, but in a game you often need to add or remove subscribers dymanically. Attaching the bus initialization to the Subscribe method makes it difficult since all the system depends on that first subscription.
If you try to publish an Event that no handler is listening the program panic since no event bus is found.
How to Reproduce
Create a new event and try to publish to it.
Problem
It makes sense to only initialize a bus if there is a handler to react to it, but in a game you often need to add or remove subscribers dymanically. Attaching the bus initialization to the Subscribe method makes it difficult since all the system depends on that first subscription.