Skip to content

connect()

Dan Stocker edited this page May 30, 2019 · 1 revision

Usage: connect(outPort, inPort)

Module: flowcode

Connects an output port to an input port. After a connection is made, when a node emits a value on one of its connected output ports, the emitted value and tag will be used to invoke all connected input ports.

It's worth noting that input ports are simply functions, and therefore it's possible to 'connect' an output port to a function, eg. console.log.

import {connect} from "flowcode";
// ...
connect(node1.o.d_out, node2.i.d_in);
connect(node2.o.d_out, console.log);
node1.i.d_in("Hello World");
// logs "Hello World!"

Clone this wiki locally