H
H
HaruAtari2015-10-12 18:37:19
Yii
HaruAtari, 2015-10-12 18:37:19

Where do you store event names in event driven systems?

Good day.
I am working on a Yii2 project where modules communicate with each other only through events. This is necessary because any module can simply be removed from the codebase or a new one added. At the same time, everything should work normally and interact with each other.
But I'm still scratching my head, how to store event names? It's just not cool to specify them as a string, you should use constants. But if the constant is in the module, then when it is deleted, the code using them will fall off. Storing the names of all events somewhere globally is also not comme il faut, because the kernel does not know which modules it operates on.
There is also the problem of unique names for events. For example, there are two modules and both have a "ticketCreated" event. The events are different, but when adding a handler, we will start listening to events for both modules at once. It seems to me that it would be necessary to add the module id or some unique string to the event name. But how to make it more beautiful?
In general, the essence of the question: how to properly store and access the names of events? And how to guarantee uniqueness of names?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question