Interfaces in Blockly
In Blockly, interfaces describe functions that an object must implement in order
to replace the default object.
You don't need to inherit from a particular class in order to implement the
interface. You can do whatever you want under the hood, as long as you provide
the correct functions and adhere to any requirements described in comments on
the interface. However, a common pattern for plugins is to extend the default
class and only override the functions you want to change.
To indicate to the type checker that you implement a specific interface,
annotate your class with @implements {InterfaceName}
.
Blockly's interfaces are defined in
core/interfaces.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["Blockly interfaces define functions objects must implement to replace default functionality."],["Implementing an interface doesn't require class inheritance, but adhering to function definitions and requirements is crucial."],["Annotate your class with `@implements {InterfaceName}` to indicate interface implementation to the type checker."],["While flexibility exists in implementation, extending the default class and overriding specific functions is a common pattern for plugins."],["Blockly's interface definitions are located in the `core/interfaces` directory of the repository."]]],[]]