GLFW simple event handler I wrote a simple concept of an event system in cpp.
It is uses a namespace and a global state, but normally a global state with namespaces is bad practice.

Is there a better way to do simple event handling with multiple callback functions?

header:

#ifndef EVENTS_EVENTMANAGER_H
#define EVENTS_EVENTMANAGER_H
#include &lt;glad/glad.h&gt;
#include &lt;GLFW/glfw3.h&gt;
#include &lt;vector&gt;
#include &lt;functional&gt;

namespace eventmanager
{   

    //resize event
    static std::vector&lt;std::function&lt;void(GLFWwindow*, int, int)&gt;&gt; resizeEventCallbacks;
    void resizeEvent(GLFWwindow *window, int width, int hight);
    void subscribeResize(std::function&lt;void(GLFWwindow*, int, int)&gt; callback);
}

#endif //EVENTS_EVENTMANAGER_H


cpp:

#include "events/eventmanager.h"

void eventmanager::resizeEvent(GLFWwindow *window, int width, int hight)
{
    for (auto &amp;callback: eventmanager::resizeEventCallbacks)
    {
        callback(window, width, hight);
    }
}

void eventmanager::subscribeResize(std::function&lt;void(GLFWwindow *, int, int)&gt; callback)
{
    eventmanager::resizeEventCallbacks.push_back(callback);
}


usage:

eventmanager::subscribeResize([&amp;](GLFWwindow *window, int width, int hight) {
            ...

            });
I see one major issue:

static std::vector&lt;std::function&lt;void(GLFWwindow*, int, int)&gt;&gt; resizeEventCallbacks;


You should never put a static variable declaration like that in a header. That will cause every file that includes the header to have a local copy of that variable. What you probably want is to put that declaration in the .cpp file so that it is local to that file only. The resizeEventCallbacks is an implementation detail that should be known only to eventmanager.cpp functions.