Module hooks

Behaviours: gen_server.

Data Types

hook()

hook() = {atom(), atom(), non_neg_integer()} | {atom(), atom(), non_neg_integer(), integer()}

hookname()

hookname() = any()

hooks()

hooks() = [{hookname(), [hook()]}]

Function Index

all/2execute all hooks for this HookName and return all results.
all_till_ok/2execute all hooks for the HookName until one return ok or {ok, Val}.
disable_plugin/1disable a plugin.
enable_plugin/1enable a plugin This function will start an application if not started and register hooks from it if none have been registered before.
enable_plugin/2enable a plugin and load paths if needed.
mreg/1register multiple hooks.
munreg/1disable multiple hooks.
only/2call the top priority hook for the HookName.
reg/3register a Module:Fun/Arity as hook, the function name become the hook name.
reg/4register Module:Fun/Arity for the hook HookName.
reg/5register Module:Fun/Arity for the hook HookName with a priority (default is 0).
run/2run all hooks registered for the HookName.
run_fold/3fold over all hooks registered for HookName, and return Acc.
unreg/3unregister Module:Fun/Arity, the function name is the hook.
unreg/4unregister Module:Fun/Arity for the hook HookName.
unreg/5unregister Module:Fun/Arity registered for the hook HookName with a priority.

Function Details

all/2

all(HookName::hookname(), Args::list()) -> [any()]

execute all hooks for this HookName and return all results

all_till_ok/2

all_till_ok(HookName::hookname(), Args::list()) -> ok | {ok, any()} | {error, term()}

execute all hooks for the HookName until one return ok or {ok, Val}. Otherwise it will return all other results as error.

disable_plugin/1

disable_plugin(Application::atom()) -> ok

disable a plugin

enable_plugin/1

enable_plugin(Application::atom()) -> ok | {error, term()}

enable a plugin This function will start an application if not started and register hooks from it if none have been registered before. Hooks are loaded from the hooks key in the application environnement

enable_plugin/2

enable_plugin(Application::atom(), Paths::[string()]) -> ok | {error, term()}

enable a plugin and load paths if needed

mreg/1

mreg(Hooks::hooks()) -> ok | {error, term()}

register multiple hooks

munreg/1

munreg(Hooks::hooks()) -> ok

disable multiple hooks

only/2

only(HookName::hookname(), Args::list()) -> any() | hooks_not_found

call the top priority hook for the HookName

reg/3

reg(Module::atom(), Fun::atom(), Arity::non_neg_integer()) -> ok | {error, term()}

register a Module:Fun/Arity as hook, the function name become the hook name.

reg/4

reg(HookName::hookname(), Module::atom(), Fun::atom(), Arity::non_neg_integer()) -> ok | {error, term()}

register Module:Fun/Arity for the hook HookName

reg/5

reg(HookName::hookname(), Module::atom(), Fun::atom(), Arity::non_neg_integer(), Priority::integer()) -> ok | {error, term()}

register Module:Fun/Arity for the hook HookName with a priority (default is 0)

run/2

run(HookName::hookname(), Args::list()) -> ok

run all hooks registered for the HookName. Execution can be interrupted if an hook return the atom stop.

run_fold/3

run_fold(HookName::hookname(), Args::list(), Acc::any()) -> Acc2::any()

fold over all hooks registered for HookName, and return Acc. interuptiuo can be interupted if the hook return stop in thacase the latest Acc will be returned or {stop, Acc}, in the case the Acc will be returned. In other cases the value returned by the hook will be given to the next function.

unreg/3

unreg(Module::atom(), Function::atom(), Arity::non_neg_integer()) -> ok

unregister Module:Fun/Arity, the function name is the hook

unreg/4

unreg(HookName::hookname(), Module::atom(), Fun::atom(), Arity::non_neg_integer()) -> ok

unregister Module:Fun/Arity for the hook HookName

unreg/5

unreg(HookName::hookname(), Module::atom(), Fun::atom(), Arity::non_neg_integer(), Priority::integer()) -> ok

unregister Module:Fun/Arity registered for the hook HookName with a priority


Generated by EDoc, Nov 3 2015, 00:07:52.