Block Protocol – Action Module
This package implements the Block Protocol Action module for blocks and embedding applications.
To get started:
yarn add @blockprotocol/action or npm install @blockprotocol/action
- Follow the instructions to use the action module as a block or an embedding application
Blocks
To create a ActionBlockHandler, pass the constructor:
- An
element in the block
callbacks to respond to messages from the embedder
- You should register a callback for the
updateAction message, which allows embedding application to set new `labels for block actions.
To tell the embedding application what elements will dispatch actions, call the availableActions function.
Send this message again if the available actions change.
To send an action message, you call the action function.
Embedding applications
To create a ActionEmbedderHandler, pass the constructor:
- An
element wrapping the block
callbacks to respond to messages from the block
- you should register callbacks for
availableActions to do something with the actions the block advises are possible
action to process individual action reports
To update the label in an action, call updateAction. The block should respond with the updated availableActions.