To create a new function or connect to a new framework, library, or custom piece of hardware not currently included in the nio Block Library at blocks.n.io, you can develop your own custom block. To create a custom block, follow these block development resources as well as the develop a custom block tutorial in workshops.
You can adopt one of two philosophies when creating a block:
Blocks are simple, generic, and reusable. Examples of generic blocks can be found at both the nio Block Library at blocks.n.io and the nio-blocks repository on GitHub. Blocks developed with this approach have a single function and you can chain blocks together to develop complex behaviors.
Blocks can be complex or built for a single use. You would not likely use this block for more than the service it was defined for. For example, a block might contain a script to run a series of calculations for a model. Instead of a complicated chain of blocks, a single block may encompass the entire model. You could also design a single block to parse a Tweet in a unique way that would not be reused.
Add a custom block to the System Designer
Your custom blocks can be added to your nio instance from within the nio System Designer. To add a custom block, click on the custom block template under the available tab in the block library. Enter the custom block's repository link in the modal and click accept. The block will now show up under the installed tab of the block library.
Manually install custom blocks
Custom blocks can also be manually installed for local use in the nio System Designer by adding them to your project's
blocks/ directory as a submodule with the
git submodule add [repository link]
command, and restarting your local nio instance.
Submit your block to the nio Block Library
Create a new block
Begin development of your block with the
nio newblock command.
Run this command from the
blocks/ directory of your nio project.
nio newblock <new_block>
newblock command clones the
block_template repository at https://github.com/nio-blocks/block_template, renames all of the example files, and sets the initial commit for your new block.
If you need to first create a nio project, use the nio-cli
nio new <new_project>
For more information about your project directory, refer to the
project_template repository at https://github.com/niolabs/project_template
Use the examples provided in developing your block to guide you in creating your custom block.
For a tutorial to step you through block development, go to workshops.n.io.