Skip to content

Instantly share code, notes, and snippets.

@Anticom
Created May 8, 2014 08:51
Show Gist options
  • Save Anticom/e99f87698d26cbfe7403 to your computer and use it in GitHub Desktop.
Save Anticom/e99f87698d26cbfe7403 to your computer and use it in GitHub Desktop.
NoFlo counting component
noflo = require 'noflo'
class CoffeeCounter extends noflo.Component
description: 'This is my test description.'
icon: 'gear'
constructor: ->
@current = 0
@inPorts =
up: new noflo.Port 'bang'
down: new noflo.Port 'bang'
reset: new noflo.Port 'bang'
@outPorts =
out: new noflo.Port 'bang'
@inPorts.up.on 'data', =>
@current++;
@outPorts.out.send @current
@inPorts.down.on 'data', =>
@current--;
@outPorts.out.send @current
@inPorts.reset.on 'data', =>
@current = 0;
@outPorts.out.send @current
exports.getComponent = -> new CoffeeCounter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment