What is the best way to create new nodes and use it in Node-red app. Something like the class concepts in c#. My idea is to create a node to use as a template in different situations, like a form data enter to transfer data to PLC. It should be possible to define the connect communication and use it as a recipe.
Thanks
You can easily use the javascript classes to define your nodes, for example:
module.exports = function(RED) {
class flexdashCtrl {
// config: name, fd_container
constructor(config) {
RED.nodes.createNode(this, config)
...
this.on("input", msg => {
...
}
}
But I'm not sure that's what you were asking about?
uibuilder makes extensive use of shared classes - specifically single-instance classes. It also uses at least 1 external package for a standardised event-handling class. Though it doesn't go as far as defining the node itself as a class but rather uses a restructured set of functions that makes defining more complex nodes a lot easier and enables easier parsing of the different elements. I've used those principals in a number of nodes now.
Where I can find some documentation and samples ?
For uibuilder? The GitHub repo: GitHub - TotallyInformation/node-red-contrib-uibuilder: Easily create data-driven web UI's for Node-RED using any (or no) front-end library.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.