NoFlo: Subgraphs as components

Skip to first unread message

Henri Bergius

Dec 14, 2012, 4:43:15 AM12/14/12

This is a bit of clarification on how subgraphs work in NoFlo 0.2
onwards, since there was a question about it:

* Any NoFlo graph can EXPORT some of its input and output ports to
give more convenient names (so you can use IN instead of SOMENODE.IN,
* Any NPM module (the way you package and distribute libraries in
Node.js) can provide both graphs and components that NoFlo
applications can use
* From the "end-user perspective", there is no difference whether a
node runs a subgraph or a (programmed) component, but the API has a
"isSubgraph" method to check this for UI purposes

A good example is probably the NoFlo YAML module which provides some
programmed components:

It also provides one reusable graph:

All of these are declared in the package.json so that NoFlo's
ComponentLoader finds them:

You just need to install the noflo-yaml package inside your project
and these components/subgraphs become available:

Here is an example of a NoFlo program that utilizes these graphs:

It simply does the following:
* Reads the contents of the given file
* Sends it to the yaml/ParseFrontmatter subgraph to be parsed
* ...and displays the results in STDOUT

Obviously real-world NoFlo programs are usually more sophisticated :-)


Henri Bergius
Motorcycle Adventures and Free Software

Microblogs: @bergie

Kenneth Kan

Dec 17, 2012, 6:58:22 PM12/17/12
Oooooh! Now I get it! This is indeed brilliant! Superior to what came before it.

Does it mean the `'Graph.fbp' -> GRAPH Graph(Graph)` syntax will be deprecated?
Reply all
Reply to author
0 new messages