Skip to content

Node class

Bo HOU edited this page Jul 8, 2016 · 9 revisions

Node class

Node

constructor(options, eventemitter)

Node constructor

-options: [any] - optional, any information you want to pass to node instance

-eventemitter: [Eventemitter] - optional, if you want the node to share a single event emitter use this parameter

Downstream API

push(signal)

Push a signal to the node.

-signal: [any] - the signal you want to push to node

-return: current node

onReceive(signal)

Handle received signal. Usually you don't need to override this method, the default implementation delegates the signal handling to three methods:

  • onSignal(signal) : handles the signal
  • onError(error) : handles the error
  • onEnd(signal) : handles the end

-signal: [any] - the signal to handle

-return: current node

send(signal)

Send a signal to the downstream nodes

-signal : the signal to send

-return: current node

Upstream API

pull(cmd)

Request a signal to the upstream node by sending a command.

-cmd: [any] - the cmd in your request

-return: current node

onRequest(cmd)

Handle received request from downstream nodes. For most operator, you don't need to override this method, it by default call request() method to pass the request to upstream.

-cmd: [any] - the command to handle

-return: current node

request(cmd)

Make a request to upstream

-cmd : the cmd to request

-return: current node

Clone this wiki locally