Comparing version 1.0.2 to 1.0.3
NoFlo ChangeLog | ||
=============== | ||
## 1.0.3 (November 24th 2017) | ||
* Added support for running arbitrary NoFlo graphs via `noflo.asCallback`. You can call this function now with either a component name, or a `noflo.Graph` instance | ||
## 1.0.2 (November 17th 2017) | ||
@@ -5,0 +9,0 @@ |
@@ -41,5 +41,19 @@ // NoFlo - Flow-Based Programming for JavaScript | ||
prepareNetwork = function(component, options, callback) { | ||
var network; | ||
// If we were given a graph instance, then just create a network | ||
if (typeof component === 'object') { | ||
component.componentLoader = options.loader; | ||
network = new Network(component, options); | ||
// Wire the network up | ||
network.connect(function(err) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return callback(null, network); | ||
}); | ||
return; | ||
} | ||
// Start by loading the component | ||
return options.loader.load(component, function(err, instance) { | ||
var def, graph, inPorts, network, nodeName, outPorts, port; | ||
var def, graph, inPorts, nodeName, outPorts, port; | ||
if (err) { | ||
@@ -77,4 +91,3 @@ return callback(err); | ||
runNetwork = function(network, inputs, options, callback) { | ||
var inPorts, inSockets, outPorts, outSockets, process, received; | ||
process = network.getNode(options.name); | ||
var inPorts, inSockets, outPorts, outSockets, received; | ||
// Prepare inports | ||
@@ -84,4 +97,7 @@ inPorts = Object.keys(network.graph.inports); | ||
inPorts.forEach(function(inport) { | ||
var portDef, process; | ||
portDef = network.graph.inports[inport]; | ||
process = network.getNode(portDef.process); | ||
inSockets[inport] = internalSocket.createSocket(); | ||
return process.component.inPorts[inport].attach(inSockets[inport]); | ||
return process.component.inPorts[portDef.port].attach(inSockets[inport]); | ||
}); | ||
@@ -93,4 +109,11 @@ // Subscribe outports | ||
outPorts.forEach(function(outport) { | ||
var portDef, process; | ||
portDef = network.graph.outports[outport]; | ||
process = network.getNode(portDef.process); | ||
outSockets[outport] = internalSocket.createSocket(); | ||
process.component.outPorts[outport].attach(outSockets[outport]); | ||
process.component.outPorts[portDef.port].attach(outSockets[outport]); | ||
outSockets[outport].from = { | ||
process: process, | ||
port: portDef.port | ||
}; | ||
return outSockets[outport].on('ip', function(ip) { | ||
@@ -109,3 +132,3 @@ var res; | ||
socket = outSockets[port]; | ||
process.component.outPorts[port].detach(socket); | ||
socket.from.process.component.outPorts[socket.from.port].detach(socket); | ||
} | ||
@@ -112,0 +135,0 @@ outSockets = {}; |
@@ -11,3 +11,3 @@ { | ||
"author": "Henri Bergius <henri.bergius@iki.fi>", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
639228
5604