Events are a powerful tool to escape and interact between various pieces of functionality. In general, there are only a few methods:
- \Neoan3\Core\Event::listen($eventname, $callbackFunction )
- \Neoan3\Core\Event::listenAll($callbackFunction )
- \Neoan3\Core\Event::dispatch($eventname, $callbackFunction )
// example in default.php: \Neoan3\Core\Event::listen('Core::beforeInit', fn($event) => var_dump($event))
You can dispatch custom events as needed using Event::dispatch. Here we want to give you a quick look at existing core-events:
Earliest event fired. This event happens AFTER resources are loaded and BEFORE any methods, instances or functions are called.
This event happens AFTER a route has been searched for and BEFORE a 404 redirect and header gets served.
This event happens AFTER the API handler has been initialized and BEFORE processing of the request begins.
This event happens AFTER the API has completed the request and BEFORE the response is sent to the client.
This event happens on multiple occasions AFTER an issue was encountered and BEFORE a response is sent to the client.