2 ms·
It doesn't have to be that complicated. Set up a list of callbacks that need to occur when a specific event is emitted, and call those callbacks. You can also
by falcolas 4y ago
It doesn't have to be that complicated. Set up a list of callbacks that need to occur when a specific event is emitted, and call those callbacks.
You can also make it dynamic by having a "register_event_hook" function that puts a callback on the event hook list. Tune for performance as necessary.
I generally include these in the controller which emits the event, or as an ancestor class for those controllers.
And if your needs evolve to the point that it's simpler to use a framework later, you'll understand your needs better and you'll be able to pick one that will best work for you.