Function on


#include <src/uvw/emitter.h>

template <typename E>
Connection< E > on(Listener< E > f)


Registers a long-lived listener with the event emitter.

This method can be used to register a listener that is meant to be invoked more than once for the given event type.
The Connection object returned by the method can be freely discarded. It can be used later to disconnect the listener, if needed.

Listener is usually defined as a callable object assignable to a std::function<void(const E &, T &), where E is the type of the event and T is the type of the resource.


f - A valid listener to be registered.

Connection object to be used later to disconnect the listener.

Mentioned in


Lines 238-241 in src/uvw/emitter.h.

template<typename E>
Connection<E> on(Listener<E> f) {
    return handler<E>().on(std::move(f));

Add Discussion as Guest

Log in