Hi @mikeS7 ,
Nice to hear that you are in the mood for extending the blockly node.
Have moved your question to this Blockly discussion, because I don't want to go to much off-topic in Andrew's discussion. And I want to have also 'at least' the opinion from @cymplecy and @TotallyInformation , who are at the moment the two most important men in my life...
At the moment I'm not quite sure how we need to proceed with this. In the 0.19 release the node.id and node.name have been added to the function node API. And now in the 0.20 release the function node API is again updated to support environment variables.
We can easily add an environment-block to support environment variables (next to msg / flow / global / node), and add the functionality to the server-side code: the server-side code is 100% identical to the function node! But - in contradiction to the function node - our blockly node can be installed e.g. on an old Node-RED version 0.17 release (which doesn't support environment variables). What should we do in that case, to avoid things will explode?
- We could hide the environment-block in the toolbox, but then users will start looking like crazy (since they meanwhile have seen a tutorial on the web demonstrating that block).
- We could let the user drop it in its workspace, and show a warning icon (like in the node-send block) for older versions. And during code generation we could simply generate a node.error('Node-RED version ... does not support environment variables via API).
- Others ...
Moreover I don't like having to copy the function node code for every Node-RED release. Would prefer that I could somehow just call the function node's code under the hood. Then Blockly is always in sync with the function node. I think this would even be better: then we always use the function node code of the Node-RED version we are running on! If we are running on an older version, then the function node API would be automatically more limited. But not sure at the moment how I could do that, i.e. something like this I suppose:
function BlocklyNode(n) {
// Delegate the request to the function node code ...
FunctionNode(n);
}
RED.nodes.registerType("Blockly",BlocklyNode);
Any thoughts from anybody on this one ?