Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::runtime::EventBus Class Reference

Type-erased event bus. More...

#include <event_bus.hpp>

Public Member Functions

 EventBus ()
 ~EventBus ()
 EventBus (const EventBus &)=delete
EventBusoperator= (const EventBus &)=delete
 EventBus (EventBus &&)=delete
EventBusoperator= (EventBus &&)=delete
template<typename T>
void publish (const T &event)
template<typename T>
::aria::Subscription subscribe (std::function< void(const T &)> handler)
template<typename T>
::aria::Subscription subscribe_on (IDispatcher &dispatcher, std::function< void(const T &)> handler)
 Subscribe with a dispatcher — incoming events are marshalled to the dispatcher's thread (e.g.
void clear ()

Static Public Member Functions

static EventBusglobal () noexcept
 Process-wide global event bus.

Detailed Description

Type-erased event bus.

Subscribe to any type T, publish any T. Singleton accessor returns the same instance process-wide because the definition lives in the runtime shared library.

Constructor & Destructor Documentation

◆ EventBus() [1/3]

aria::runtime::EventBus::EventBus ( )

◆ ~EventBus()

aria::runtime::EventBus::~EventBus ( )

◆ EventBus() [2/3]

aria::runtime::EventBus::EventBus ( const EventBus & )
delete

◆ EventBus() [3/3]

aria::runtime::EventBus::EventBus ( EventBus && )
delete

Member Function Documentation

◆ operator=() [1/2]

EventBus & aria::runtime::EventBus::operator= ( const EventBus & )
delete

◆ operator=() [2/2]

EventBus & aria::runtime::EventBus::operator= ( EventBus && )
delete

◆ global()

EventBus & aria::runtime::EventBus::global ( )
staticnoexcept

Process-wide global event bus.

◆ publish()

template<typename T>
void aria::runtime::EventBus::publish ( const T & event)
inline

◆ subscribe()

template<typename T>
::aria::Subscription aria::runtime::EventBus::subscribe ( std::function< void(const T &)> handler)
inlinenodiscard

◆ subscribe_on()

template<typename T>
::aria::Subscription aria::runtime::EventBus::subscribe_on ( IDispatcher & dispatcher,
std::function< void(const T &)> handler )
inlinenodiscard

Subscribe with a dispatcher — incoming events are marshalled to the dispatcher's thread (e.g.

the UI thread) before the handler fires. Use this if your handler touches UI and publishers may call you from a worker thread. The dispatcher is borrowed and must outlive the subscription and any publish call already in progress. Releasing the subscription suppresses queued handlers that have not started.

◆ clear()

void aria::runtime::EventBus::clear ( )

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