#To see the problem, run this inlet, with console open
#Type characters in a comment line and you will see new instances created, and restart sequence
#Then set the value of normalCallback to true and type some more comment characters and you will see the problem
#My proposed workaround could be made part of tributary and only the modified setTimeout exposed to the user
#Make it easy to see in console what just happened
#Nice to make this a persistent config preference
console.clear()
#I am using this instance number to show the problem with callbacks
#Might be useful to have this happen automatically
tributary.TBInstance ?= 0
instance = ++tributary.TBInstance
#How many times has the callback been called in this instance
seq = 1
#change behavior for callbacks: toggle true or false
normalCallback = false
callback = () ->
console.log "I am a callback #{seq++} for instance #{instance}"
#If normalCallback is false, then setTimeout called in usual way
if normalCallback
setTimeout callback, 1000
else
#conditional callback, only if we are latest instance
if instance is tributary.TBInstance
setTimeout callback, 1000
setTimeout callback, 1000