Skip to content

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

ParameterTypeDescription
methodNamestringThe name of the method to add.
implementation(this, ...args) => TReturnThe 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) });
});