JavaScript in Add-on libraries: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Add 'stub' marker and explanation)
m (Standardizing capitalization of "Add-on")
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
= JavaScript Context =
= JavaScript Context =


A JavaScript context is created for an add-on to isolate the JavaScript environment from other add-ons.
A JavaScript context is created for an Add-on to isolate the JavaScript environment from other Add-ons.


This context is not persisted across sessions or clients.
This context is not persisted across sessions or clients.
It is destroyed when the add-on is removed and recreated when the add-on is updated.
It is destroyed when the Add-on is removed and recreated when the Add-on is updated.
The {{code|onInit}} event for the add-on should be used to create any JavaScript objects that need to be created on startup of the add-on.
The {{code|onInit}} event for the Add-on should be used to create any JavaScript objects that need to be created on startup of the Add-on.


It is believed that the JavaScript context created uses the namespace string of the add-on library, but this is not documented (currently).
It is believed that the JavaScript context created uses the namespace string of the Add-on library, but this is not documented (currently, as of 2023-11-14).

Latest revision as of 23:59, 17 November 2023

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.

JavaScript Context

A JavaScript context is created for an Add-on to isolate the JavaScript environment from other Add-ons.

This context is not persisted across sessions or clients. It is destroyed when the Add-on is removed and recreated when the Add-on is updated. The onInit event for the Add-on should be used to create any JavaScript objects that need to be created on startup of the Add-on.

It is believed that the JavaScript context created uses the namespace string of the Add-on library, but this is not documented (currently, as of 2023-11-14).