Last active
February 22, 2016 14:43
-
-
Save trustmaster/2a292e23e61642fa148d to your computer and use it in GitHub Desktop.
WirePattern must die
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussion here: noflo/noflo#205