Skip to content

Subscribables

Ondolin edited this page Mar 7, 2021 · 1 revision

The torchly API is event-based. Therefore it is possible to subscribe to changes of some objects like players (not jet supported) or characters.

The subscribable class provides one attribute called subscriptionCallbacks. This array contains all the callback functions which subscribe to the object. IMPORTANT: This array is not meant to be changed manually.

To add a subscription use the function subscribe(callback: Function): void. The callback function gets executed each time a change to this particular object happens.

To remove a subscription use the function unsubscribe(callback: Function): void this will remove all functions from the subscription list which are equal to the passed function. Please inform yourself when two functions are equal (a === b).

Clone this wiki locally