Trait that gives components the ability to unsubscribe from events. More...
#include <Unsubscribable.h>
Public Member Functions | |
| virtual | ~Unsubscribable ()=default |
| template<typename EnumType> | |
| void | unsubscribe (EnumType event) |
| Unsubscribe from a single event by enum value. | |
| void | unsubscribeAll () |
| Remove all event subscriptions for this component. | |
Trait that gives components the ability to unsubscribe from events.
Unsubscribable is a separate trait inherited by Core. It provides unsubscribe() and unsubscribeAll() without touching EventReceiver, avoiding the diamond ambiguity that would arise if unsubscribe logic lived in EventReceiver (which is multiply inherited through traits).
Both built-in ml::Event values and user-defined manifest event enums work identically — any enum value is converted to a size_t key via EnumKey::get().
unsubscribeAll() is called automatically by Core's destructor. Explicit calls are only needed for mid-lifecycle cleanup.Definition at line 45 of file Unsubscribable.h.
|
virtualdefault |
|
inline |
Unsubscribe from a single event by enum value.
Works with any enum type — ml::Event for built-in events, or a manifest Event enum for custom events.
If called during a _EventsManager::fire() iteration the removal is deferred until the iteration completes.
| EnumType | Any enum type. Enforced at compile time. |
| event | The enum value identifying the event to remove. |
Definition at line 61 of file Unsubscribable.h.
| void ml::Unsubscribable::unsubscribeAll | ( | ) |
Remove all event subscriptions for this component.
Removes every subscription registered across all event names. Called automatically by Core's destructor.
If called during a _EventsManager::fire() iteration the removal is deferred until the iteration completes.