Operator: do

The synchronous version of actuator() api. The actSync function does not take a callback function as argument. Its return value will be injected to signal’s __result__ field.


NS.do(comment : string, inputs : map, outputs : map, actSync : function) : Node


Arguement Type Description
comment string optional, the comment of the actuator
inputs map optional, the input description
outputs map optional, the output description
actSync function optional, the act function, it throws Error or returns the result. If an error is threw, an error signal will be sent, otherwise, the return value will be injected to the signal as __result__ field

actSync function signature:

function actSync(signal : Signal) : any

If error is threw, an ERROR signal is sent to stream, otherwise the return value is injected to the signal with a special name : __result__. You can access it with signal.getResult()


Type Description
Node the actuator node

Create a sync actuator

const ns = collar.ns('collarjs.demo.actuatorSync');
const input = ns.input('input');

  .do("print data", signal => {  // print signal data

input.push({data : "Hello World"});

results matching ""

    No results matching ""