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-08 12:03:40 -07:00
parent 15938b1d67
commit 33c9583969

@ -51,9 +51,10 @@ The class defines the following functions/events:
<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.
This function causes messages 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 undefined, no message is sent on.
- If `msg` is a single message, it is sent to all 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.
@ -89,6 +90,20 @@ Three log level functions are provided for convenience. They format the log mess
<a name="server-createNode" href="#wiki-server-createNode">#</a> RED.nodes.<b>createNode</b>(<i>node</i>,<i>definition</i>)
This function should be the first thing called in a node's constructor function, passing in `this` and the node's definition object:
function InjectNode(n) {
RED.nodes.createNode(this,n);
<a name="server-registerType" href="#wiki-server-registerType">#</a> RED.nodes.<b>registerType</b>(<i>type</i>,<i>node</i>)
After defining a node's constructor, it needs to be registered with this function. This must be done immediately after the constructor and before any additional functions are added to its prototype, for example, if the node defines its own [close](#server-Node-close) function.
function InjectNode(n) {
...
...
}
RED.nodes.registerType("inject",InjectNode);
<a name="server-library-register" href="#wiki-server-library-register">#</a> RED.library.<b>register</b>(<i>type</i>)