//
// Created by sebastian on 05.08.26.
//

#ifndef COLORRACE_EVENTBUS_H
#define COLORRACE_EVENTBUS_H
#include <functional>

namespace engine {
    template<typename Event>
    class EventBus {
    public:
        using Handler = std::function<void(Event&)>;

        void subscribe(Handler handler) {
            m_handlers.push_back(handler);
        }

        void publish(Event& event) const {
            for (const auto& handler : m_handlers) {
                handler(event);
            }
        }
    private:
        std::vector<Handler> m_handlers;
    };
} // engine

#endif //COLORRACE_EVENTBUS_H
