I am using Template.prototype.autorun() inside a Template.prototype.onRendered() to reactively update a template. I want multiple autoruns so only the portion with updated data is run again. Here is how I imagine it would look:
... for d in [0..6] @autorun -> console.log d deplanements = [ 'deplanements' ] for h in [0..23] deplanements[h + 1] = 0 Flights.find( eibt: $gte: new Date( weekStart.year(), weekStart.month(), weekStart.date() + d, h ) $lt: new Date( weekStart.year(), weekStart.month(), weekStart.date() + d, h + 1 ) ).forEach (flight) -> deplanements[h + 1] += flight.passengers charts[d].load columns: [ xLabels deplanements  ]
On first render it works fine, in the console I see 0, 1... 6 and the template looks as expected. However, when I modify the collection, d prints out as 7. I don't see how that is possible. If i unroll the loop manually it works fine:
... @autorun -> d = 0 console.log d ... @autorun -> d = 1 console.log d ... ...