Addepar / ember-charts

https://opensource.addepar.com/ember-charts/
Other
784 stars 131 forks source link

Use afterRender for draw calls #226

Closed mixonic closed 5 years ago

mixonic commented 5 years ago

There were two downsides to how thie scheduling of draw was implemented. First, scheduling into actions means the drawing will occur before the next rendering pass. In a messy codebase the rendering pass might itself be setting state, so we may want to go after it. Second, the once method will always execute on the first scheduled task. If a property changes three times and each time a) schedules draw and b) schedules another task you will end up executing draw,task,task,task when what you want is task,task,task,draw. This can also happen if property changes interleave in the actions queue with the draw tasks.

This implementation moved to afterRender which is less efficient but defensive. It also uses a strategy for running draw once which defers drawing until the last possible entry in the queue.