noflo-core
Version:
NoFlo Essentials
38 lines (31 loc) • 860 B
text/coffeescript
noflo = require 'noflo'
class RepeatDelayed extends noflo.AsyncComponent
description: 'Forward packet after a set delay'
icon: 'clock-o'
constructor: ->
= []
= 0
= new noflo.InPorts
in:
datatype: 'all'
description: 'Packet to be forwarded with a delay'
delay:
datatype: 'number'
description: 'How much to delay'
default: 500
= new noflo.OutPorts
out:
datatype: 'all'
.delay.on 'data', () =>
super()
doAsync: (packet, callback) ->
timer = setTimeout =>
.out.send packet
callback()
.splice .indexOf(timer), 1
,
.push timer
shutdown: ->
clearTimeout timer for timer in
= []
exports.getComponent = -> new RepeatDelayed