textmode.js / plugins / TextmodePluginContext / extendLayer
Method: extendLayer()
ts
extendLayer<TArgs, TReturn>(methodName, implementation): void;Extend TextmodeLayer instances with a new method. The method will be available on all existing and future layer instances.
Type Parameters
| Type Parameter |
|---|
TArgs extends unknown[] |
TReturn |
Parameters
| Parameter | Type | Description |
|---|---|---|
methodName | string | The name of the method to add. |
implementation | (this, ...args) => TReturn | The implementation function. this will be bound to the TextmodeLayer instance. |
Returns
void
Example
ts
api.extendLayer('synth', function(source: SynthSource) {
// `this` is the TextmodeLayer instance
this.setPluginState('synth', { source, compiled: compile(source) });
});