Implemented using Observer pattern without separate classes for Observer/Subject.
There is global EventManager object to transfer our events to receivers.
There is event queue that will be processed at the end on the game loop to avoid blocking events.
You can subsribe/unsubscribe to any event:
Events::Subscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose));Events::Unsubscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose));
Where Applciation::OnWindowClose is the member function with Derived from Event parameter:
bool Application::OnWindowClose(const Events::WindowCloseEvent& e)
Benefits
event queue;
we don't use dependency injection, that can be turn to very deep and dangerous callstack of OnEvent function calls;
simple subscription model using just callback function with particular Event.
Brief overview
Implemented using Observer pattern without separate classes for Observer/Subject. There is global EventManager object to transfer our events to receivers. There is event queue that will be processed at the end on the game loop to avoid blocking events.
You can subsribe/unsubscribe to any event:
Events::Subscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose));
Events::Unsubscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose));
Where Applciation::OnWindowClose is the member function with Derived from Event parameter:
bool Application::OnWindowClose(const Events::WindowCloseEvent& e)
Benefits