cl-cookbook icon indicating copy to clipboard operation
cl-cookbook copied to clipboard

How to implement hooks?

Open foretspaisibles opened this issue 7 years ago • 4 comments

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.

foretspaisibles avatar Jun 14 '18 06:06 foretspaisibles

Where do you put CLOS' method combination (:after, :before, :around methods) in this picture ?

vindarel avatar Jun 14 '18 13:06 vindarel

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

vindarel avatar Jan 21 '19 17:01 vindarel

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.

vindarel avatar Jun 17 '19 11:06 vindarel

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).

vindarel avatar Sep 17 '19 10:09 vindarel