Skip to content

Instantly share code, notes, and snippets.

@trustmaster
Created February 24, 2016 04:38
Show Gist options
  • Save trustmaster/aa85e518db2444234526 to your computer and use it in GitHub Desktop.
Save trustmaster/aa85e518db2444234526 to your computer and use it in GitHub Desktop.
Example component prototype
c = new noflo.Component
c.desciption = 'A component that posts on behalf of user'
c.inPorts = new noflo.InPorts
db:
datatype: 'object'
control: true
user:
datatype: 'object'
post:
datatype: 'object'
c.outPorts = new noflo.OutPorts
id:
datatype: 'int'
c.process = (input, output, done) ->
return unless input.has 'db', 'user', 'post' # or input.has 'alternative'
[db, user, post] = input.receive 'db', 'user', 'post'
db.data 'post'
.insert
user: user.data.id
title: post.data.title
text: post.data.text
, 'id'
.then (rows) ->
output.sendDone
id: rows[0].id # new noflo.IP 'data', rows[0].id
.catch done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment