@node-red/runtime.hooks

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

add(hookId, callback)

Register a handler to a named hook

Parameters:
Name Type Description
hookId String

the name of the hook to attach to

callback function

the callback function for the hook

remove(hookId)

Remove a handled from a named hook

Parameters:
Name Type Description
hookId String

the name of the hook event to remove - must be name.label