Skip to main content

Home > blockly > Extensions > register

Extensions.register() function

Registers a new extension function. Extensions are functions that help initialize blocks, usually adding dynamic behavior such as onchange handlers and mutators. These are applied using Block.applyExtension(), or the JSON "extensions" array attribute.

Signature:

export declare function register<T extends Block>(name: string, initFn: (this: T) => void): void;

Parameters

ParameterTypeDescription
namestringThe name of this extension.
initFn(this: T) => voidThe function to initialize an extended block.

Returns:

void

Exceptions

{Error} if the extension name is empty, the extension is already registered, or extensionFn is not a function.