Skip to content

Commit

Permalink
New component for sending edges message to runtime, refs noflo/noflo-…
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Jan 30, 2017
1 parent 7f18357 commit 6f0559e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
6 changes: 4 additions & 2 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"components/ListenNetwork.coffee",
"components/SendComponent.coffee",
"components/SendGraph.coffee",
"components/ListComponents.coffee"
"components/ListComponents.coffee",
"components/SendEdges.coffee"
],
"json": [
"spec/data/component.json",
Expand All @@ -51,8 +52,9 @@
"ListGraphs": "components/ListGraphs.coffee",
"ListNetworks": "components/ListNetworks.coffee",
"SendComponent": "components/SendComponent.coffee",
"SendEdges": "components/SendEdges.coffee",
"SendGraph": "components/SendGraph.coffee",
"SendGraphChanges": "components/SendGraphChanges.coffee"
}
}
}
}
32 changes: 32 additions & 0 deletions components/SendEdges.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
noflo = require 'noflo'

exports.getComponent = ->
c = new noflo.Component
c.description = 'Send edges selected by user to runtime'
c.inPorts.add 'edges',
datatype: 'array'
required: yes
c.inPorts.add 'runtime',
datatype: 'object'
required: yes
c.outPorts.add 'out',
datatype: 'array'
c.outPorts.add 'error',
datatype: 'object'

noflo.helpers.WirePattern c,
in: 'edges'
params: 'runtime'
out: 'out'
async: true
, (data, groups, out, callback) ->
unless c.params.runtime.canDo
return callback new Error 'Incorrect runtime instance'
unless c.params.runtime.isConnected()
# Pass-through since there is no connection
out.send data
do callback
return
c.params.runtime.sendNetwork 'edges', data
out.send edges
do callback
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@
"ListGraphs": "components/ListGraphs.coffee",
"ListNetworks": "components/ListNetworks.coffee",
"SendComponent": "components/SendComponent.coffee",
"SendEdges": "components/SendEdges.coffee",
"SendGraph": "components/SendGraph.coffee",
"SendGraphChanges": "components/SendGraphChanges.coffee"
}
}
}
}

0 comments on commit 6f0559e

Please sign in to comment.