4.4 Module classy_hook

Module responsible for managing the hooks.

4.4.1 Types

hook()

A handle of a hook. It can be used to unregister the hook.

prio()
-type prio() :: integer().

Functions registered into a hookpoint with higher priority are executed first.

hookpoint()
-type hookpoint() :: atom().

Identifier of a hookpoint.

4.4.2 Functions

first_match(Hookpoint, Args)
-spec first_match(hookpoint(), list()) -> {ok, _Val} |
                                          undefined.

Return result of the first hook that returned {ok, _} for a given set of arguments.

all(Hookpoint, Args)
-spec all(hookpoint(), list()) -> ok | {error, _}.

Ensure that all functions hooked into Hookpoint return ok.

If any function returns other value or throws an exception, this function returns {error, _}.

fold(Hookpoint, Args, Acc0)
-spec fold(hookpoint(), list(), A) -> A.

Fold over all functions registered in Hookpoint. Accumulator argument is appended to the Args list.

Errors are ignored (logged).

foreach(Hookpoint, Args)
-spec foreach(hookpoint(), list()) -> ok.

Apply all functions hooked into Hookpoint to arguments Args.

Errors are ignored (logged).

unhook(Key)
-spec unhook(hook()) -> ok.

Remove a previously inserted hook.

insert(Hookpoint, Hook, Prio)
-spec insert(hookpoint(), fun(), prio()) -> hook().

JavaScript license information