#The Angular Way of Repeating an Action
19 messages · Page 1 of 1 (latest)
Observables. timer or interval probably. But specifics matter
it was for the purpose of canvas animation. but I'm just going to use requestAnimationFrame
Depends
it changes properties on this.ctx
so I would assume it triggers the change detection
oh I see, I should pass the canvas ctx as the state paramater to the work function instead of binding this
Zone will do it automatically 🙂
I would have assumed you wouldn't want Angular Zone involved in animations. But I also wouldn't want animations in Angular beyond CSS. So I have no idea what you are doing. Seems like you are coming from an entirely different direction to Angular than the one I am familiar with.
If I was animating something, I would run entirely outside the Angular Zone and directly mutate the DOM on the target (not relying on Angular data binding at all)
but what if the data im animating has some reliance on angular bound data?
i ended up just running it in zone and using set interval with requestAnimationFrame, i'll have to make sure its not triggering change detection every render frame though
If it's in the zone, it is.