Reputation: 742
I was working with requestAnimationFrame(), and I thought,
say I had a function
function draw(){
...
...
requestAnimationFrame(draw);
}
now lets say I called draw()
twice,
draw();
draw();
does this mean 2 different loops will be flowing async together ?, can this cause RAM overloading or similar ?
Upvotes: 0
Views: 39
Reputation: 137084
requestAnimationFrame(callback)
pushes callback in a stack of animation frames that will all get executed (fifo) at the same time, during the next painting event loop iteration.
So yes, you will have two different loops running, but not really async.
For the RAM a function is not a problem, however what you do in draw will be done twice in a raw and that's rarely what you want.
But having two different animation loops is a normal use case.
Upvotes: 1