cl-cookbook
cl-cookbook copied to clipboard
How to implement hooks?
A common strategy to allow extendable behaviour is to propose event hooks: code consuming the hook can register a function to be triggered when code exposing the hook encounters a specific condition.
How to implement hooks? (Which library to use?)
Should hints about this go to the Functions library or to some other section. Maybe a new function “Dependency injection” or something like this?
See also #178.
Where do you put CLOS' method combination (:after, :before, :around methods) in this picture ?
for reference this is how the Next browser does it: it registers hooks https://github.com/atlas-engineer/next/blob/master/source/hook.lisp and then uses a macro to define commands that automatically search for available hooks: https://github.com/atlas-engineer/next/blob/master/source/command.lisp#L25
see also this library: https://gitlab.com/Gnuxie/method-hooks When CLOS method combination kind of allow only one hook per method, this library allows an arbitrary number of them.
And this: https://github.com/scymtym/architecture.hooks/ which is now used in the Next browser.
See also advices with a cross-implementation library (in the debug page).