Hooks beta
Class of @v12-engine/engine
ts
export declare class HooksThe handlers of every hook of one world
Members
constructor
ts
constructor(world: World);Constructs a new instance of the Hooks class
add
ts
add(def: HookDef): void;Adds a handler. One with the same id on the same hook is replaced
handlers
ts
handlers(hook: AnyHook): string[];Ids of the handlers of a hook, in the order they run
has
ts
has(hook: AnyHook): boolean;Whether a hook has any handlers. For hooks run very often, to not even put the event together when nobody listens
remove
ts
remove(hook: AnyHook, id: string): void;Takes the handler with the id off the hook; nothing happens when there is none
run
ts
run<K extends HookName>(hook: K, event: Uncancelled<HookEvents[K]>): HookEvents[K];Runs the handlers of a hook on the event, in order, and hands the event back for the caller to read
run
ts
run<T>(hook: HookKey<T>, event: Uncancelled<T>): T;Runs the handlers of a game's own hook on the event in order and returns the event