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 <switchboard/export.h>
8#include <any>
9#include <memory>
10#include <string>
11
12#include <switchboard/Event.hpp>
13
14namespace switchboard {
15
19class SWITCHBOARDSDK_EXPORT EventEmitter {
20public:
21
22 using Callback = std::function<void(const std::string&, const SBAny&)>;
23
28
32 virtual ~EventEmitter();
33
42 unsigned int addEventListener(const std::string& eventName, Callback callback);
43
51 bool removeEventListener(unsigned int listenerID);
52
53protected:
60 void emitEvent(const std::string& eventName, const SBAny& data);
61
62private:
63 class Impl;
64 std::unique_ptr<Impl> pImpl;
65};
66
67}
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.