Register Node
Node?
This is where we define our node structure like input/output/properties, title, and description
Can be ported easily on different programming languages
That's mean we can't call specific language's API
Any interaction with specific language's API like input/output must be registered on Interface.
This supposed to run on NodeJS too, so don't control any HTML element directly inside this.
Don't declare or use variable outside of function context/scope.
Just think you want to create a compatible logic to be ported on Browser/Node.js/PHP/Python.
Just let this
nodecontrol and communicate with your registeredinterface.
// Register a new node
// -> (namespace, callback)
Blackprint.registerNode('math/multiply', function(node, iface){
// node = Blackprint flow handler
// iface = ScarletsFrame element handler
// Give it a title
iface.title = "Random";
// Give it a description
iface.description = "Multiply something";
// If the node would have value that can be exported to JSON
// It must being set inside options object
iface.options = {};
//> We will use `default` node type, so let this empty or undefined
// iface.interface = 'bp/default';
// ... Other information below ...
});Reserved handler property
node here is the Blackprint flow handler from the example above.
Property
Description
inputs
An array of input port registration
outputs
An array of output port registration
properties
An array of node property registration Still draft feature
importing
A boolean indicating if this node is being imported/created
Below are reserved property that filled with function/callback
Property
Arguments
Description
init
()
Callback function to be run after current handle and all node was initialized
request
(targetPort, sourceNode)
Callback when other node's input port are requesting current node's output value
update
(Cable)
Callback when current input value are updated from the other node's output port
imported
(options)
This is a callback after node was created, imported options should be handled here
For the detailed example you can see from this repository.
Node port registration
The port must be registered on the node and Blackprint will create internal control with ScarletsFrame so the port can being used for sending or obtaining data from other node's port.
Last updated
Was this helpful?