R-Type 0.1
Loading...
Searching...
No Matches
busEvent Class Reference

Type indexed publish and subscribe event bus. More...

#include <events/busEvents.hpp>

Public Member Functions

template<typename E >
void subscribe (std::function< void(const E &event)> func)
 Registers a handler for one event type.
 
template<typename E >
void publish (const E &event)
 Calls every handler registered for the event type.
 

Detailed Description

Type indexed publish and subscribe event bus.

Handlers run synchronously on the thread that publishes the event.

Member Function Documentation

◆ subscribe()

template<typename E >
void busEvent::subscribe ( std::function< void(const E &event)> func)
inline

Registers a handler for one event type.

Template Parameters
EEvent type.
Parameters
funcFunction called with every published event of type E.

◆ publish()

template<typename E >
void busEvent::publish ( const E & event)
inline

Calls every handler registered for the event type.

Template Parameters
EEvent type.
Parameters
eventEvent passed to the handlers.