Toast Engine
Loading...
Searching...
No Matches
event::Listener Class Reference

manages the lifetime, subscription, and unsubscription of callbacks More...

#include <listener.hpp>

Public Member Functions

 Listener (bool state)
template<typename TEvent>
void unsubscribe (std::string_view name) noexcept
 unsubscribes every event in type TEvent with that name
template<typename TEvent, EventCallback< TEvent & > F>
void subscribe (std::string name, F &&callback, char priority=0) noexcept
 subscribes a callback to an TEvent
template<typename TEvent, EventCallback< TEvent & > F>
void subscribe (F &&callback, char priority=0) noexcept
 subscribes a callback to an TEvent (name will be set to "unnamed")
void enabled (bool state)
 enables/disables the callbacks in the listener
auto enabled () const -> bool

Detailed Description

manages the lifetime, subscription, and unsubscription of callbacks

Member Function Documentation

◆ enabled()

auto event::Listener::enabled ( ) const -> bool
nodiscard
Returns
enabled state

◆ subscribe() [1/2]

template<typename TEvent, EventCallback< TEvent & > F>
void event::Listener::subscribe ( F && callback,
char priority = 0 )
noexcept

subscribes a callback to an TEvent (name will be set to "unnamed")

Parameters
callback
priority(higher priority happens first)

◆ subscribe() [2/2]

template<typename TEvent, EventCallback< TEvent & > F>
void event::Listener::subscribe ( std::string name,
F && callback,
char priority = 0 )
noexcept

subscribes a callback to an TEvent

Parameters
nameof the callback
callback
priority(higher priority happens first)
Here is the caller graph for this function:

◆ unsubscribe()

template<typename TEvent>
void event::Listener::unsubscribe ( std::string_view name)
noexcept

unsubscribes every event in type TEvent with that name

Parameters
nameevent callback name/s to remove
Here is the caller graph for this function:

The documentation for this class was generated from the following files: