i cant believe this was that easy

This commit is contained in:
altalk23 2024-02-25 10:00:57 +03:00
parent 9fea8d8320
commit d8ac85b44a
2 changed files with 17 additions and 0 deletions

View file

@ -37,6 +37,8 @@ namespace geode {
using Ev = DispatchEvent<Args...>;
using Callback = ListenerResult(Args...);
EventListenerPool* getPool() const override;
ListenerResult handle(utils::MiniFunction<Callback> fn, Ev* event) {
if (event->getID() == m_id) {
return std::apply(fn, event->getArgs());

View 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];
}