Methods
-
<static> notify( name [, payload [, onBehalf ] ] ) → {Object}
-
Description
Allow custom events to be fired using the Warp Gate event system. Is broadcast to all users, including the initiator. Like Hooks, these functions cannot be awaited for a response, but all event functions executing on a given client will be evaluated in order of initial registration and the processing of the event functions will respect (and await) returned Promises.
Parameters
Name Type Attributes Default Description name
string Name of this event. Watches and triggers use this name to register themselves. Like Hooks, any string can be used and it is dependent upon the watch or trigger registration to monitor the correct event name.
payload
object <optional> {sceneId: canvas.scene.id, userId: game.user.id} eventData {Object} The data that will be provided to watches and triggers and their condition functions.
onBehalf
string <optional> game.user.id User ID that will be used in place of the current user in the cases of a relayed request to the GM (e.g. dismissal).
Returns
Details
-
<static> remove( id )
-
Description
Removes a
watch
ortrigger
by its provided id -- obtained by the return value ofwatch
andtrigger
.Parameters
Name Type Description id
number Numerical ID of the event function to remove.
Details
-
<static> trigger()
-
Description
Identical to
warpgate.event.watch
, except that this function will only be called once, after the condition is met.Details
-
<static> watch( name, fn [, condition ] ) → {number}
-
Description
Similar in operation to
Hooks.on
, with two exceptions. First, the provided function can be asynchronous and will be awaited. Second, an optionalconditionFn
parameter is added to help compartmentalize logic between detecting the desired event and responding to said event.Parameters
Name Type Attributes Default Description name
String Event name to watch for; It is recommended to use the enums found in
warpgate.EVENT
fn
function Function to execute when this event has passed the condition function. Will be awaited
condition
function <optional> ()=>true Optional. Function to determine if the event function should be executed. While not strictly required, as the
fn
function could simply return as a NOOP, providing this parameter may help compartmentalize "detection" vs "action" processing.Returns
Details