I am back with another component for the Ice Cream Framework that I am slowly building out. A lot of this is a exercise in development, learning and research.

Last time I came to you with the Ice Cream Database which has since then gotten a new release to 1.3.0 which has removed the connection class and the closeConnection($name) as well as closeAllConnections() methods.

This time, we get to explore events in Ice Cream. The goal was to keep it dead simple. You define an event, you define a listener, you associate the two, you register and you dispatch.

The event is passed into the listener to give you access to the event.

This is similar to that of how Laravel does this. I added a small twist, which is similar to how Symfony does things.

You can register the function to call on the listener when the event is dispatched:

$eventHandler->register('page.viewed', PageViewEvent::class, Listener::class, 'onAction');

As you can see, we register a name, the event class, the listener class and the action to call on the listener when the event is dispatched.

You can then do $eventHandler->dispatch('page.viewed');

For more information checkout the README

Right now the event system is kept as simple as possible to be able to get the initial version out the door.

Feedback is always welcome, feel free to open PR's and Issues should you find any :)