1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Updated API Reference (markdown)

Nick O'Leary 2013-09-07 15:54:00 -07:00
parent 9e90bf23a9
commit 36cad4b30f

@ -2,7 +2,7 @@
### Nodes
- [RED.nodes.Node](#server-Node) - the super class all Nodes extend.
- [node.send(msg)](#server-Node-send)
- [node.receive(msg)](#server-Node-receive)
- ['input' event](#server-Node-input)
- [node.close](#server-Node-close)
- [node.log(msg)](#server-Node-log)
- [node.warn(msg)](#server-Node-warn)
@ -40,28 +40,42 @@
- RED.sidebar.addTab(title,content)
- RED.notify(msg,type)
***
<a name="server-Node" href="#wiki-server-Node">#</a> RED.nodes.<b>Node</b>
All nodes extend this class. It handles the wiring between nodes and other things. It should not be instantiated directly, rather [RED.nodes.createNode](#server-createNode) should be called from the
constructor of the sub-class.
<a name="server-Node-send" href="#wiki-server-Node-send">#</a> node.<b>send</b>(<i>msg</i>)
This function causes the message(s) to be sent on to any nodes wired to this one. A node can have multiple outputs and each output can be wired to multiple nodes.
- If `msg` is a single message, it is sent on to any nodes wired to the first output.
- If `msg` is an array, each element of the array is passed to the corresponding output.
- If any of these elements is itself an array, each element of that array is sent to the connected nodes in order.
<a name="server-Node-input" href="#wiki-server-Node-input">#</a> '<b>input</b>' event
This event is emitted when the node receives an inbound message. The node should register a listener for this event in order to handle the message. If the node has outputs, it must call [send](#server-Node-send) The usual pattern if to create a listener for this event in the nodes constructor.
this.on("input",function(msg) {
var msg = {topic:this.topic,payload:this.payload};
if (msg.payload == "") { msg.payload = Date.now(); }
this.send(msg);
});
<a name="server-Node" href="#wiki=server-Node">#</a> RED.nodes.<b>Node</b>
All nodes extend this class. It handles the wiring between nodes and other things. It should not be instantiated directly, rather [RED.nodes.createNode](#server-createNode) should be used.
<a name="server-Node-send" href="#wiki=server-Node-send">#</a> node.<b>send</b>(<i>msg</i>)
<a name="server-Node-receive" href="#wiki=server-Node-receive">#</a> node.<b>receive</b>(<i>msg</i>)
<a name="server-Node-close" href="#wiki-server-Node-close">#</a> node.<b>close</b>()
<a name="server-Node-close" href="#wiki=server-Node-close">#</a> node.<b>close</b>()
<a name="server-Node-log" href="#wiki-server-Node-log">#</a> node.<b>log</b>(<i>msg</i>)
<a name="server-Node-log" href="#wiki=server-Node-log">#</a> node.<b>log</b>(<i>msg</i>)
<a name="server-Node-warn" href="#wiki-server-Node-warn">#</a> node.<b>warn</b>(<i>msg</i>)
<a name="server-Node-warn" href="#wiki=server-Node-warn">#</a> node.<b>warn</b>(<i>msg</i>)
<a name="server-Node-error" href="#wiki-server-Node-error">#</a> node.<b>error</b>(<i>msg</i>)
<a name="server-Node-error" href="#wiki=server-Node-error">#</a> node.<b>error</b>(<i>msg</i>)
<a name="server-createNode" href="#wiki-server-createNode">#</a> RED.nodes.<b>createNode</b>(<i>node</i>,<i>definition</i>)
<a name="server-createNode" href="#wiki=server-createNode">#</a> RED.nodes.<b>createNode</b>(<i>node</i>,<i>definition</i>)
<a name="server-registerType" href="#wiki-server-registerType">#</a> RED.nodes.<b>registerType</b>(<i>type</i>,<i>node</i>)
<a name="server-registerType" href="#wiki=server-registerType">#</a> RED.nodes.<b>registerType</b>(<i>type</i>,<i>node</i>)
<a name="server-library-register" href="#wiki=server-library-register">#</a> RED.library.<b>register</b>(<i>type</i>)
<a name="server-library-register" href="#wiki-server-library-register">#</a> RED.library.<b>register</b>(<i>type</i>)