Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
HOOK.LUA(8)		    System Manager's Manual		   HOOK.LUA(8)

NAME
       hook.lua	-- FreeBSD hook	module

DESCRIPTION
       hook.lua	 contains  functionality for defining hook types and attaching
       hooks.  Hooks are functions used	to attach custom behaviors at  pre-de-
       fined points in loader execution.  These	pre-defined points are what we
       refer to	as "hook types".  Hooks	may also take an optional data parame-
       ter, which may or may not be populated by the caller.

       Before  using  the  functionality  provided by hook.lua,	it must	be in-
       cluded with a statement such as the following:

	     local hook	= require("hook")

   Exported functions
       The following functions are exported from hook.lua:

	     hook.registerType(hooktype)
				Adds hooktype as a recognized hook type.  This
				allows functions to be added to	run when hooks
				of    this    type    are    invoked	 using
				hook.runAll(hooktype).

	     hook.register(hooktype, hookfunc)
				Register hookfunc to be	run when hooks of type
				hooktype are invoked.

	     hook.runAll(hooktype)
				Invoke all hooks registered for	type hooktype.
				Hooks  are  invoked in the order in which they
				are registered.

   Hook	Naming Guidelines
       Hook names should consist of the	name of	the module  they  are  defined
       in,  as	well as	a verb describing when the hook	is executed, separated
       by  a  period.	For  example,  "config.reloaded"  is  defined  in  the
       config.lua(8) module and	run when the configuration is reloaded.

EXAMPLES
       To register a hook to be	run when configuration is reloaded:

	     local hook	= require("hook")

	     local function configuration_was_reloaded()
		     print("Configuration was reloaded!")
	     end

	     hook.register("config.reloaded", configuration_was_reloaded)

AUTHORS
       The    hook.lua	 file	was   originally   written   by	  Kyle	 Evans
       <kevans@FreeBSD.org>.

FreeBSD	13.2			April 28, 2020			   HOOK.LUA(8)

NAME | DESCRIPTION | EXAMPLES | AUTHORS

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=hook.lua&sektion=8&manpath=FreeBSD+14.0-RELEASE+and+Ports>

home | help