Custom Modules
Context, Tools, and Events
What the constructor context contains, which tools are worth using, and how to publish or consume module events safely.
Context, Tools, and Events
This part of the custom-module docs describes the injected runtime surface you work with after extending StringModule.
Every custom module constructor receives a StringContext.
TypeScript
constructor(context: StringContext) {
super(context);
}
The base class stores that context on protected fields like:
this.toolsthis.datathis.settingsthis.eventsthis.centersthis.hoverthis.objectManager
That surface is too important to keep on one long page, so it is split into focused deep dives.
What belongs here
This cluster answers four different authoring questions:
- What exactly is available in
StringContext? - Which tools should a custom module reuse instead of reinventing?
- How should live runtime state be read from
this.data? - How should custom modules subscribe to and emit events?
Practical Rule
Good custom modules usually stay inside this surface:
- read shared runtime state from
this.data - read author config through attribute mapping and
this.settings - reuse
this.toolsfor parsing, interpolation, and writes - use
this.eventsfor safe runtime communication
If a module starts depending heavily on private manager internals instead of these injected surfaces, that is usually a design smell.