forked from node-red/node-red
-
Notifications
You must be signed in to change notification settings - Fork 0
Input node feature definitions
zobalogh edited this page Oct 29, 2014
·
8 revisions
This page defines the features and design conventions that each input node should adhere to. The page is currently under development and changes to its contents are possible. Once the behaviour is agreed upon, these conventions are going to be migrated onto the Node-RED website for easy reference.
- Create a new msg JavaScript object for every distinctive output they wish to generate. This is to be achieved for example by:
node.on("input", function(msg) {
msg = {};
doSomethingWithMsg(node, msg);
});
* It is essential for msg to be an object, otherwise it cannot be extended with additional fields in further nodes
- Have clearly defined behaviour that triggers new msg objects to be sent upon meeting clearly defined conditions
- If a condition forces the node to send multiple messages, they should all be individual msg objects rather than arrays of information
- Poll at regular intervals to see if msg trigger conditions are met:
node.interval = setInterval(function() {
node.emit("input", {});
}, REPEAT_IN_MILLIS);
* Alternatively they could fire by being triggered by callbacks => TODO define behaviour here
* Reserve the right not to send anything at all, ever if conditions are never met