BlockExtension

public interface BlockExtension

A BlockExtension allows programmatic configuration of blocks, extra initialization, or custom behaviors to be added to blocks. They are also the preferred mechanism to create and set Mutators on blocks.

BlockExtensions must be registered using registerExtension(String, BlockExtension). For convenience, implementations of AbstractBlocklyActivity can override the configureBlockExtensions() to register several extensions at start up.

All extensions used by the blocks found in src/main/assets/default/ are defined in getExtensions(), the default return value of {@linkplain AbstractBlocklyActivity#configureBlockExtensions()}.

Block definitions can refer to these extensions two ways. If a extension installs a {@linkplain Mutator} on a block, the block definition should declare its use with the "mutation" JSON attribute. There can only be one mutator extension. All other extensions must use the "extension" JSON attribute, an array of extension names. When a block is constructed, applyTo(Block) will be called on the new block.

See guide on extensions and mutators.

Public Method Summary

abstract void
applyTo(Block block)
Applies the extension to the provided block.

Public Methods

public abstract void applyTo (Block block)

Applies the extension to the provided block.

Parameters
block The block to update