libnick 2024.12.0
A cross-platform base for native Nickvision applications.
|
libnick events are designed to easily integrate within your classes to easily notify consumers of changes in state of an object.
Let's take a look at Nickvision::App::DataFileBase
and how it defines and uses events.
Here we can see how Nickvision::App::DataFileBase
defines a saved
event, exposes it to the consumer, and triggers/invokes the event within its save
method.
A consumer of Nickvision::App::DataFileBase
can easily subscribe to the event and have its handler called when the configuration object is saved:
This program will print Config saved.
as a result of the event being invoke once the save method was called.