Message reference
The properties and methods of a message in the server code.
On this page
A message carries data from an output of one node to an input of another. instance.message receives it, usually as $:
instance.message = function($) {
var data = $.data;
$.send('output', data);
};Every message must be sent on or ended. See Inputs, outputs and messages.
API
property
$.data
The data of the message.
$.data
property
$.input
The id of the input on which the message arrived.
$.input
property
$.output
The id of the output from which the message came.
$.output
property
$.fromid
The id of the node that sent the message.
$.fromid
property
$.fromcomponent
The id of the component of the node that sent the message.
$.fromcomponent
property
$.toid
The id of the node that received the message.
$.toid
property
$.repo
An object that travels with the message from node to node.
$.repoA node stores values in it, and the nodes after it read them.
$.repo.orderid = 1001;
$.send('output');
property
$.refs
References shared by all copies of the message.
$.refsThe Route component stores the HTTP request in $.refs.controller, and the Response component answers through it.
property
$.instance
The node that received the message.
$.instance
property
$.main
The FlowStream.
$.main
property
$.error
The error stored by $.throw().
$.error
method
$.send(output, [data])
Sends the message to the nodes connected to an output.
$.send(output, [data])| Parameter | Type | Description |
|---|---|---|
output |
String |
The id of the output. |
data? |
Object |
New data for the message. |
Returns Number The number of nodes that received the message.
Without data, the message keeps its data. With null as output, it goes to every output that has a connection. When no node receives it, the message ends.
$.send('output', { name: 'Jane' });
method
$.destroy()
Ends the message.
$.destroy()Call it for every message that you do not send on. $.end() does the same.
method
$.throw(error)
Reports an error to the designer and stores it in $.error.
$.throw(error)| Parameter | Type | Description |
|---|---|---|
error |
String |
The error message. |
It does not end the message.
$.throw('Demo error');
$.destroy();
method
$.replace(text, [data])
Fills in variables, and other keys from the message.
$.replace(text, [data])| Parameter | Type | Description |
|---|---|---|
text |
String |
The text with keys in braces. |
data? |
Object |
Values to use instead of the message. |
Returns String The text with the values.
Works like instance.replace(), but keys that are not variables are read from the message, for example {data.name}. $.variables() does the same.
method
$.rewrite(data)
Replaces the data of the message.
$.rewrite(data)| Parameter | Type | Description |
|---|---|---|
data |
Object |
The new data. |
Returns Object The message.
method
$.status(data, [delay])
Sends a status of the node that received the message.
$.status(data, [delay])The same as instance.status().
method
$.on(name, callback)
Listens to an event of the message.
$.on(name, callback)| Parameter | Type | Description |
|---|---|---|
name |
String |
The event, for example end. |
callback |
Function |
The function to call. |
The end event runs when the message and all the copies sent from it have ended. $.once() listens once and $.off() stops listening.
$.on('end', function() {
instance.status('finished');
});
$.send('output');