refactor: move event disptacher into service locator

This commit is contained in:
k0t9i
2023-10-16 23:38:01 +04:00
parent b948273172
commit ede55a870e
15 changed files with 160 additions and 94 deletions

View File

@@ -11,10 +11,8 @@ class EventDispatcher
public:
using Delegate = std::function<void(const Event&)>;
static EventDispatcher& GetInstance() {
static EventDispatcher instance;
return instance;
}
EventDispatcher() = default;
virtual ~EventDispatcher() = default;
void Dispatch(const Event& evt)
{
@@ -36,12 +34,6 @@ public:
m_Handlers[eventName].push_back(handler);
}
private:
EventDispatcher() = default;
virtual ~EventDispatcher() = default;
EventDispatcher(const EventDispatcher&) = delete;
EventDispatcher& operator=(const EventDispatcher&) = delete;
private:
std::unordered_map<std::string, std::vector<Delegate>> m_Handlers;
};