From dd4cec84bfe5706a5e06f48724b0d318390e8fdd Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 17 Mar 2015 13:40:12 +0000 Subject: [PATCH] Add node.send/on to Function node --- nodes/core/core/80-function.html | 18 ++++-- nodes/core/core/80-function.js | 75 ++++++++++++++++-------- test/nodes/core/core/80-function_spec.js | 14 +++-- 3 files changed, 72 insertions(+), 35 deletions(-) diff --git a/nodes/core/core/80-function.html b/nodes/core/core/80-function.html index c415f9791..70c4290e8 100644 --- a/nodes/core/core/80-function.html +++ b/nodes/core/core/80-function.html @@ -39,15 +39,21 @@

The message is passed in as a JavaScript object called msg.

By convention it will have a msg.payload property containing the body of the message.

-

If your node need to log anything use the node object: +

Logging and Error Handling

+

To log any information, or report an error, the following functions are available:

-

The function should return the messages it wants to pass on to the next nodes - in the flow. It can return:

+

The Catch node can also be used to handle errors. To invoke a Catch node, + pass msg as a second argument to node.error:

+
node.error("Error",msg)
+

Sending messages

+

The function can either return the messages it wants to pass on to the next nodes + in the flow, or can call node.send(messages).

+

It can return/send: