Skip to content

Instantly share code, notes, and snippets.

@trustmaster
Created April 1, 2016 10:49
Show Gist options
  • Save trustmaster/e2ec8ccb23c9d9a3e6a429121522abad to your computer and use it in GitHub Desktop.
Save trustmaster/e2ec8ccb23c9d9a3e6a429121522abad to your computer and use it in GitHub Desktop.
Substreams and scalar example
c = new noflo.Component
inPorts:
streamy:
datatype: 'object'
description: 'Substreams'
inty:
datatype: 'int'
description: 'Scalar'
outPorts:
result:
datatype: 'object'
c.process (input, output) ->
if input.has 'streamy'
s = input.get 'streamy'
switch s.type
when 'openBracket'
c.streamy = [ s.data ]
c.streamyComplete = false
when 'data'
c.streamy.push s.data
when 'closeBracket'
c.streamyComplete = true
if input.has 'inty' and c.streamyComplete
i = input.getData 'inty'
res = doSomething c.streamy, i
c.streamyComplete = false
output.sendDone
result: res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment