mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
i cant believe this was that easy
This commit is contained in:
parent
9fea8d8320
commit
d8ac85b44a
2 changed files with 17 additions and 0 deletions
|
@ -37,6 +37,8 @@ namespace geode {
|
||||||
using Ev = DispatchEvent<Args...>;
|
using Ev = DispatchEvent<Args...>;
|
||||||
using Callback = ListenerResult(Args...);
|
using Callback = ListenerResult(Args...);
|
||||||
|
|
||||||
|
EventListenerPool* getPool() const override;
|
||||||
|
|
||||||
ListenerResult handle(utils::MiniFunction<Callback> fn, Ev* event) {
|
ListenerResult handle(utils::MiniFunction<Callback> fn, Ev* event) {
|
||||||
if (event->getID() == m_id) {
|
if (event->getID() == m_id) {
|
||||||
return std::apply(fn, event->getArgs());
|
return std::apply(fn, event->getArgs());
|
||||||
|
|
15
loader/src/loader/Dispatch.cpp
Normal file
15
loader/src/loader/Dispatch.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#include <Geode/loader/Event.hpp>
|
||||||
|
#include <Geode/utils/ranges.hpp>
|
||||||
|
#include <mutex>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
using namespace geode::prelude;
|
||||||
|
|
||||||
|
static std::unordered_map<std::string, EventListenerPool*> s_pools;
|
||||||
|
|
||||||
|
EventListenerPool* DispatchFilter::getPool() const {
|
||||||
|
if (s_pools.count(m_id) == 0) {
|
||||||
|
s_pools[m_id] = new DefaultEventListenerPool();
|
||||||
|
}
|
||||||
|
return s_pools[m_id];
|
||||||
|
}
|
Loading…
Reference in a new issue