Add docs for RED.hooks

This commit is contained in:
Nick O'Leary 2020-07-31 14:31:33 +01:00
parent 08148a07b2
commit 6f25337b99
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 12 additions and 19 deletions

View File

@ -11,6 +11,18 @@ let labelledHooks = { }
/**
* Runtime hooks engine
*
* The following hooks can be used:
*
* Message sending
* - `onSend` - passed an array of `SendEvent` objects. The messages inside these objects are exactly what the node has passed to `node.send` - meaning there could be duplicate references to the same message object.
* - `preRoute` - passed a `SendEvent`
* - `preDeliver` - passed a `SendEvent`. The local router has identified the node it is going to send to. At this point, the message has been cloned if needed.
* - `postDeliver` - passed a `SendEvent`. The message has been dispatched to be delivered asynchronously (unless the sync delivery flag is set, in which case it would be continue as synchronous delivery)
* - `onReceive` - passed a `ReceiveEvent` when a node is about to receive a message
* - `postReceive` - passed a `ReceiveEvent` when the message has been given to the node's `input` handler(s)
* - `onComplete` - passed a `CompleteEvent` when the node has completed with a message or logged an error
*
* @mixin @node-red/runtime_hooks
*/
@ -132,25 +144,6 @@ function trigger(hookId, payload, done) {
}
}
// add("preSend", function(sendEvents) {
// console.log("preSend",JSON.stringify(sendEvents));
// })
// add("preRoute", function(sendEvent) {
// console.log("preRoute",JSON.stringify(sendEvent.msg));
// })
// add("onSend", function(sendEvent) {
// console.log("onSend",JSON.stringify(sendEvent.msg));
// })
// add("postSend", function(sendEvent) {
// console.log("postSend",JSON.stringify(sendEvent.msg));
// })
// add("onReceive", function(recEvent) {
// console.log("onReceive",recEvent.destination.id,JSON.stringify(recEvent.msg))
// })
// add("postReceive", function(recEvent) {
// console.log("postReceive",recEvent.destination.id,JSON.stringify(recEvent.msg))
// })
function clear() {
hooks = {}
labelledHooks = {}