diff --git a/README.md b/README.md index 6d3ef09..268f6a8 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,44 @@ int main() { ``` -### 2. Assertion +### 2. Assert (Documentation pending implementation) ### 3. Events -(Documentation pending implementation) +The Events module provides a thread and type safe signal/slot mechanism. It allows you to define custom events with any number of parameters and subscribe to them using callbacks. +#### Basic Usage +```cpp +#include +#include + +using namespace seallib; + +// Define an event that takes an int and a string +Event OnUserLogin; + +void onLogin(int id, std::string name) { + std::cout << "User " << name << " (ID: " << id << ") logged in!" << std::endl; +} + +int main() { + // 1. Subscribe to the event + auto connection = OnUserLogin.addListener(onLogin); + + // 2. Add a lambda listener + OnUserLogin.addListener([](int id, auto name) { + std::clog << "[Log] Login detected for ID: " << id << std::endl; + }); + + // 3. Trigger the event + OnUserLogin.run(42, "SomeUser"); + + // 4. Remove a listener when no longer needed + OnUserLogin.removeListener(connection); + + return 0; +} +``` ### 4. VFS