Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HTML standard timer APIs #50

Open
MylesBorins opened this issue Sep 5, 2020 · 5 comments
Open

Implement HTML standard timer APIs #50

MylesBorins opened this issue Sep 5, 2020 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@MylesBorins
Copy link
Member

As documented in https://html.spec.whatwg.org/multipage/timers-and-user-prompts.htm

@bdougie brought this in #27 (comment)

This would include:

setTimeout()
setInterval()
clearTimeout()
clearInterval()

In deno this is how it is implemented

https://github.com/denoland/deno/blob/master/cli/global_timer.rs
https://github.com/denoland/deno/blob/master/cli/rt/11_timers.js

Definitely interesting that the JavaScript runtime extensions are implemented in deno_cli not deno_core

@MylesBorins MylesBorins added enhancement New feature or request help wanted Extra attention is needed labels Sep 5, 2020
@devsnek
Copy link
Member

devsnek commented Sep 5, 2020

Can we do a promise version instead?

@MylesBorins
Copy link
Member Author

@devsnek we could, although I will admit I fail to see value in creating a new timer API that is specific to JSTime. might be worth discussing with HTML + maybe node (deno?) if other platforms would be interested in a promise based API as well

@bengl
Copy link
Contributor

bengl commented Sep 5, 2020

Regardless of API, this would still be likely blocked by #12.

@bartlomieju
Copy link

Definitely interesting that the JavaScript runtime extensions are implemented in deno_cli not deno_core

As pointed by @bengl timers require event loop. deno_core is agnostic of event loop used and thus timer are implemented in deno_cli (and are built on top of Tokio). The whole timers code is quite complex at the moment because Tokio doesn't support ordered timers (tokio-rs/tokio#1775)

FYI - we'll be moving those APIs to a separate crate in near(-ish) future.

@devsnek
Copy link
Member

devsnek commented Sep 5, 2020

for timers I would expect a thread with a timer wheel anyway, so not a huge issue for tokio to not be involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants