mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Updated API Reference (markdown)
parent
36cad4b30f
commit
6d5e95aa4c
@ -47,6 +47,8 @@
|
||||
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.
|
||||
|
||||
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.
|
||||
@ -57,7 +59,7 @@ This function causes the message(s) to be sent on to any nodes wired to this one
|
||||
|
||||
<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 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.
|
||||
|
||||
this.on("input",function(msg) {
|
||||
var msg = {topic:this.topic,payload:this.payload};
|
||||
@ -65,14 +67,25 @@ This event is emitted when the node receives an inbound message. The node should
|
||||
this.send(msg);
|
||||
});
|
||||
|
||||
|
||||
<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>)
|
||||
|
||||
|
||||
This function is called when the node is being stopped, for example when a new flow configuration is deployed. This allows the node to release any resources, such as network connections, it has open.
|
||||
|
||||
For example, the `Inject` node clears the timer if one had been set:
|
||||
|
||||
InjectNode.prototype.close = function() {
|
||||
if (this.interval_id != null) {
|
||||
clearInterval(this.interval_id);
|
||||
}
|
||||
}
|
||||
|
||||
<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-error" href="#wiki-server-Node-error">#</a> node.<b>error</b>(<i>msg</i>)
|
||||
|
||||
Three log level functions are provided for convenience. They format the log message with the time-stamp and ID of the node. If the `Debug` node is active, the log messages will appear in the debug sidebar.
|
||||
|
||||
<a name="server-createNode" href="#wiki-server-createNode">#</a> RED.nodes.<b>createNode</b>(<i>node</i>,<i>definition</i>)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user