registerOneShot

fnauto registerOneShot(Args...)(ref Hap!Args hap, void delegate(Args) @safe handler) @safe

Register a one-shot delegate handler on a Hap that detaches itself after the first invocation.

The registration is consumed before the user handler runs. This prevents re-entrant emits from re-triggering the same one-shot handler. If the user handler throws, the registration is already consumed and will not fire again.

The returned OneShotRegistration can cancel the one-shot before it fires.

Parameters

hapThe hap to register on.
handlerThe delegate handler that runs at most once.

Returns

An OneShotRegistration for cancelling the one-shot.
fnauto registerOneShot(Args...)(ref NothrowHap!Args hap, void delegate(Args) @safe nothrow handler) @safe nothrow

ditto