Search code examples
gruntjsnoflo

Using no flo components in browser


I am trying out some prototypes with noflo in the browser and currently facing some issues related to to get it up and running. Could someone please point me in the right direction ? Below is my scenario.

I want to run a FBP in my browser like below:

 var noflo=require('noflo');

var fbpString  = 
                  "'http://localhost:8000/books?tFilter=test -> IN repeat(core/Repeat)";  
                  fbpString=fbpString+"\n"+"repeat OUT -> URL sendRequest(http/SendRequest)";
                  fbpString=fbpString+"\n"+"repeat OUT -> START sendRequest";
                  fbpString=fbpString+"\n"+"sendRequest REQUEST -> REQUEST receiveResponse(http/ReceiveResponse)";
                  fbpString=fbpString+"\n"+"receiveResponse MESSAGE -> IN output(core/Output)";                   

// Load the NoFlo graph based on the FBP string
noflo.graph.loadFBP(fbpString, function (graph:any) {
// Run the graph
noflo.createNetwork(graph);
console.log('Network created');
});

I could execute a simple helloworld running using core/Output. Any idea how could I get the above scenario running ?

Currently I have a grunt noflo-browser task which packages the noflo-components (which are manually copied and placed in a 'components' folder) as mentioned in the component.json file. Am I doing it right ? Few queries:

  1. Should I be doing a manual copy of all the components that I need separately and mention it everytime in component/package json files ?
  2. How do I handle node builtin modules like http,url etc ?
  3. What about components which do not have component.json file ?

Could someone please help out ? thanks.


Solution

  • We have an example of this in the NoFlo docs.

    To build a browser-runnable NoFlo bundle you can utilize grunt-noflo-browser, as explained here