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(name: string, initFn: Function): void;

Parameters

Parameter Type Description
name string The name of this extension.
initFn Function The 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.