Skip to content

Instantly share code, notes, and snippets.

@trustmaster
Last active February 22, 2016 14:43
Show Gist options
  • Save trustmaster/2a292e23e61642fa148d to your computer and use it in GitHub Desktop.
Save trustmaster/2a292e23e61642fa148d to your computer and use it in GitHub Desktop.
WirePattern must die
c = new noflo.Component
c.desciption = 'A component that posts on behalf of user'
c.inPorts = new noflo.InPorts
timeout:
datatype: 'int'
control: true
user:
datatype: 'object'
post:
datatype: 'object'
c.outPorts = new noflo.OutPorts
result:
datatype: 'object'
## Define a process in Classic FBP style with Input facade
# Pros:
# - contains firing logic of any complexity
# Cons:
# - interface is different from Ports API
c.process = (input, output, done) ->
return unless input.has 'user', 'post', 'timeout'
[user, post] = input.receive 'user', 'post'
timeout = input.receive 'timeout'
doSomething user.data, post.data, timeout: timeout.data
.then (result) ->
output.send('result').data result,
groups: post.groups
done()
.catch done
## Define a process in Classic FBP style with direct input buffers
# Pros:
# - even more control over firing logic
# - closer to bare metal
# Cons:
# - verbose
# - may require proxying each port on each call
c.process = (input, output, done) ->
return unless input.user.contains() and input.post.contains() and input.timeout.contains()
user = input.user.receive()
post = input.post.receive()
timeout = input.timeout.receive()
doSomething user.data, post.data, timeout: timeout.data
.then (result) ->
output.result.data result,
groups: post.groups
done()
.catch done
@jonnor
Copy link

jonnor commented Jan 24, 2016

Discussion here: noflo/noflo#205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment