There are two ways to look at this:
1. The main control flow of your application is in regular JavaScript-land, and you're using your NoFlo graphs as essentially a "library".
In that case, asCallback is great for "batch-style" operation where you send some data to NoFlo, and then get results back.
const loader = new noflo.ComponentLoader();
loader.load('my-project/MyGraph', (err, instance) => {
instance.start((err) => {
// Here you can bind to ports. Using just in/out as example, but can be more
const out = noflo.internalSocket.createSocket();
const ins = noflo.internalSocket.createSocket();
// React to results from outport
out.on('ip', (ip) => {
// Received an information packet
});
// Send something
ins.send('Some data');
});
});
This way you're fully in control of the network lifecycle, and can keep a single instance of your graph running as long as your application needs it.
Depending how your graph is made, you can send/receive as long as you need.
2. Have NoFlo manage the control flow, in which case you'll want to expose your UI as "components" in NoFlo land. Typically in these cases you'd have a circular dataflow where your UI generator component can send actions as IPs to the NoFlo graph, and IPs from the rest of the graph get set as props of your UI component.
For a simplistic example, see:
This is also the architecture we used for building Flowhub/noflo-ui, basicallt implementing a Redux-like flow with pure NoFlo. See notes in: