Closed pheze closed 11 years ago
good catch ! not sure what's going on here
Kaffeine is doing things right here !
You're writing coffeescript like syntax so it is harder to point out what's wrong. Kaffeine does not uses whitespace indentation.
For kaffeine those three code blocks are the same :
for x in [1,2,3]
sleep!(100)
console.log(x)
for x in [1,2,3]
sleep!(100)
console.log(x)
for x in [1,2,3] {
sleep!(100)
}
console.log(x)
See ? you only have the sleep statement in the loop, as such, kaffeine has no statement to give to the async, so it uses an empty function.
What you really want is this:
sleep = { setTimeout #1, #0 }
for x in [1,2,3] {
sleep!(100)
console.log(x)
}
results to
var sleep; sleep = function() { return setTimeout(arguments[1], arguments[0]) }
for(x in [1,2,3]) {
sleep(100, function() {
console.log(x) })
}
yes of course ! -- Kaffeine is more like Javascript than CoffeeScript ^_^
closing for now.
This:
Results in:
Shouldn't the console.log be included in the sleep callback?