Expand all

Hook

An instance of a hook, created via mw.hook method.

Methods

add(…handler) → {Hook}static #

Register a hook handler.

Parameters:

Name Type Attributes Description
handler function repeatable

Function to bind.

Source:

Returns:

Type
Hook
Register a hook handler.

deprecate(msg) → {Hook}staticchainable #

Enable a deprecation warning, logged after registering a hook handler.

Examples

mw.hook( 'myhook' ).deprecate().fire( data );
mw.hook( 'myhook' )
  .deprecate( 'Use the "someother" hook instead.' )
  .fire( data );

NOTE: This must be called before calling fire(), as otherwise some
hook handlers may be registered and fired without being reported.

Parameters:

Name Type Description
msg string

Optional extra text to add to the deprecation warning

Source:

Returns:

Type
Hook
Enable a deprecation warning, logged after registering a hook handler.

fire(…data) → {Hook}staticchainable #

Call hook handlers with data.

Parameters:

Name Type Attributes Description
data any repeatable
Source:

Returns:

Type
Hook
Call hook handlers with data.

remove(…handler) → {Hook}static #

Unregister a hook handler.

Parameters:

Name Type Attributes Description
handler function repeatable

Function to unbind.

Source:

Returns:

Type
Hook
Unregister a hook handler.