Looks like you're abusing Bacon.onValues
, whose purpose is to create a new stream.
If you want to wait for the start of the module, just register the listener only when it has started:
sTick = Bacon.fromEventTarget emitter, 'tick'
module.onStart ->
# when module has been started
sTick.onValue ->
# Do something on each tick
For a completely FRP-style, you would use flatMap
:
sStart = Bacon.fromCallback module.onStart.bind(module)
# Watch game ticks
sTick = Bacon.fromEventTarget emitter, 'tick'
# Combine it to a new stream that is made from sTicks by each sStart event
sTicksAfterStart = sStart.flatMap -> sTick
sTickeafterStart.onValue ->
# Do something on each tick