Function once


#include <src/uvw/emitter.h>

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


Registers a short-lived listener with the event emitter.

This method can be used to register a listener that is meant to be invoked only 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.


Lines 258-261 in src/uvw/emitter.h.

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

Add Discussion as Guest

Log in