Deno: Feature Request: requestAnimationFrame

Created on 2 Jul 2019  路  12Comments  路  Source: denoland/deno

It's not a frequent usage to run animation on deno, but some code will require this API.

suggestion web

Most helpful comment

It would be good to point out any code that doesn't handle the lack of this well. rAF was often used as a proxy for minor task scheduling before things like promises were shipped natively, and code that really made use of this directly was DOM heavy stuff, which we are far away from realistically supporting. Driving this by actual use cases would be better than just just delivering an API without that additional context.

All 12 comments

It would be good to point out any code that doesn't handle the lack of this well. rAF was often used as a proxy for minor task scheduling before things like promises were shipped natively, and code that really made use of this directly was DOM heavy stuff, which we are far away from realistically supporting. Driving this by actual use cases would be better than just just delivering an API without that additional context.

Back in the day we used to polyfill this in the browser for browsers that did not support RAF. Here's the first one that popped up in a quick search:

https://gist.github.com/paulirish/1579671

Seeing as it can be implemented so easily does Deno really need to support it as a feature?

Diving into this late but I'd agree with @kitsonk that deno serves as a server-side runtime; rAF is a very client-focused implementation detail. We _do_ implement a good deal of the DOM spec but rAF is not part of the official spec so I can't see a practical use case for it here

Is there possible to run deno as a client-side runtime just like electron?

@yorkie no... Electron binds together Chromium and Node.js, so in theory someone could bind together Chromium and Deno, but that would not be this project.

we need this feature to run game logics on server side, or maybe setinterval

@VicenteFleitas setInterval exists already. What would rAF do that this doesn't?

@VicenteFleitas setInterval exists already. What would rAF do that this doesn't?

I know, I mean if we should use "setInterval" instead of "requesAnimationFrame"

I am not sure what you are saying. setInterval exists in Deno. People can already write game logics on server side.

Since no one has presented a compelling use case of what rAF would do differently then other items like queueMicrotask, and it is easily "fillable" if someone does need it to adapt other code, I am going to close this.

I am not sure what you are saying. setInterval exists in Deno. People can already write game logics on server side.

Since no one has presented a compelling use case of what rAF would do differently then other items like queueMicrotask, and it is easily "fillable" if someone does need it to adapt other code, I am going to close this.

Yes, i use setInterval, but every book a read about gamedev on js says requestAnimationFrame is best for gameloops. I think we need rAF

requestAnimationFrame only makes sense in frontend (browser) contexts. Deno is a backend context, and thus does not support rAF, nor does it need to. (e.g. WebWorkers in browsers don't support rAF either)

Correct, rAF schedules as task as part of the rendering of the page in a browser, and so you are less likely to impact layout and cause jitter/lag in the UI. None of this makes sense in Deno.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

watilde picture watilde  路  3Comments

JosephAkayesi picture JosephAkayesi  路  3Comments

somombo picture somombo  路  3Comments

kyeotic picture kyeotic  路  3Comments

zugende picture zugende  路  3Comments