Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

twine / HandlerGroup

Abstract Class: HandlerGroup โ€‹

Defined in: twine/src/core/events/group.ts:18

A set of event handlers on a helper object the module holds as a field.

The module finds groups by type, runs their registerHandlers once, and namespaces their keys by ns. The group needs no reference to the module.

Constructors โ€‹

Constructor โ€‹

new HandlerGroup(): HandlerGroup

Returns โ€‹

HandlerGroup

Properties โ€‹

ns โ€‹

abstract readonly ns: string

Defined in: twine/src/core/events/group.ts:20

This group's namespace: every key is prefixed ${ns}/, and own bodies go in its folder.

Methods โ€‹

collect() โ€‹

collect(): EventHandler[]

Defined in: twine/src/core/events/group.ts:96

This group's handlers, namespaced under ns. Registers them on first use.

Returns โ€‹

EventHandler[]


every() โ€‹

protected every(ticks, fn, opts?): void

Defined in: twine/src/core/events/group.ts:67

Every as a group method: run fn every ticks ticks.

Parameters โ€‹

ticks โ€‹

number

fn โ€‹

(c) => void

opts? โ€‹

Omit<OnOptions, "once" | "every"> = {}

Returns โ€‹

void


on() โ€‹

Call Signature โ€‹

protected on(key, detector, fn, opts?): void

Defined in: twine/src/core/events/group.ts:42

Register a handler. A latched one needs a key (bare - ns is prepended on harvest), since its latch is saved in the world under it.

Parameters โ€‹
key โ€‹

string

detector โ€‹

Detector

fn โ€‹

(c) => void

opts? โ€‹

OnOptions

Returns โ€‹

void

Call Signature โ€‹

protected on(detector, fn, opts): void

Defined in: twine/src/core/events/group.ts:48

Register a handler. A latched one needs a key (bare - ns is prepended on harvest), since its latch is saved in the world under it.

Parameters โ€‹
detector โ€‹

Detector

fn โ€‹

(c) => void

opts โ€‹

OnOptions & object

Returns โ€‹

void


rearm() โ€‹

protected rearm(ctx, dp, moduleName, keys?): void

Defined in: twine/src/core/events/group.ts:76

Re-arms this group's latched handlers in keys, or all of them if omitted.

Parameters โ€‹

ctx โ€‹

FunctionContext

dp โ€‹

Datapack

moduleName โ€‹

string

keys? โ€‹

readonly string[]

Returns โ€‹

void


registerHandlers() โ€‹

abstract registerHandlers(): void

Defined in: twine/src/core/events/group.ts:27

Declares this group's handlers with on/every. Called once by the framework.

Runs after the subclass constructor, so fields are set.

Returns โ€‹

void

Released under the MIT License ยท Credits
These docs were written with AI; the layout and every page have been reviewed by a human.