Static
Private
#idsA mapping of hooked functions by their assigned ID
Static
Private
#idAn incrementing counter for assigned hooked function IDs
Static
eventsA mapping of hook events which have functions registered to them.
Static
onRegister a callback handler which should be triggered when a hook is triggered.
The unique name of the hooked event
The callback function which should be triggered when the hook event occurs
Options which customize hook registration
Only trigger the hooked function once
An ID number of the hooked function which can be used to turn off the hook later
Static
onceRegister a callback handler for an event which is only triggered once the first time the event occurs. An alias for Hooks.on with {once: true}
The unique name of the hooked event
The callback function which should be triggered when the hook event occurs
An ID number of the hooked function which can be used to turn off the hook later
Static
offStatic
callCall all hook listeners in the order in which they were registered Hooks called this way can not be handled by returning false and will always trigger every hook callback.
The hook being triggered
Rest
...args: any[]Arguments passed to the hook callback functions
Were all hooks called without execution being prevented?
Static
callCall hook listeners in the order in which they were registered. Continue calling hooks until either all have been called or one returns false.
Hook listeners which return false denote that the original event has been adequately handled and no further hooks should be called.
The hook being triggered
Rest
...args: any[]Arguments passed to the hook callback functions
Were all hooks called without execution being prevented?
Static
onNotify subscribers that an error has occurred within foundry.
The method where the error was caught.
The error.
Optional
options: { Additional options to configure behaviour.
A message which should prefix the resulting error or notification.
The level at which to log the error to console (if at all).
The level at which to spawn a notification in the UI (if at all).
Additional data to pass to the hook subscribers.
Static
Private
#callPrivate
Call a hooked function using provided arguments and perhaps unregister it.
The hooked function entry
Arguments to be passed
A simple event framework used throughout Foundry Virtual Tabletop. When key actions or events occur, a "hook" is defined where user-defined callback functions can execute. This class manages the registration and execution of hooked callback functions.