Switchboard Extension SDK
Loading...
Searching...
No Matches
EventEmitter.hpp
1//
2// Created by Balazs Kiss on 2025. 02. 06..
3//
4
5#pragma once
6
7#include <any>
8#include <memory>
9#include <string>
10#include <switchboard/Event.hpp>
11#include <switchboard/export.h>
12
13namespace switchboard {
14
18class SWITCHBOARDSDK_EXPORT EventEmitter {
19public:
20 using Callback = std::function<void(const std::string&, const SBAny&)>;
21
26
30 virtual ~EventEmitter();
31
40 unsigned int addEventListener(const std::string& eventName, Callback callback);
41
49 bool removeEventListener(unsigned int listenerID);
50
51protected:
58 void emitEvent(const std::string& eventName, const SBAny& data);
59
60private:
61 class Impl;
62 std::unique_ptr<Impl> pImpl;
63};
64
65}
bool removeEventListener(unsigned int listenerID)
Removes an event listener from the object.
void emitEvent(const std::string &eventName, const SBAny &data)
Emits an event.
virtual ~EventEmitter()
Destructor for the EventEmitter class.
unsigned int addEventListener(const std::string &eventName, Callback callback)
Adds a new event listener to the object.
EventEmitter()
Constructor for the EventEmitter class.