-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Scheduling: setTimeout and setInterval #3423
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -127,7 +127,7 @@ setTimeout(() => { clearInterval(timerId); alert('stop'); }, 5000); | |||
``` | |||
|
|||
```smart header="Time goes on while `alert` is shown" | |||
In most browsers, including Chrome and Firefox the internal timer continues "ticking" while showing `alert/confirm/prompt`. | |||
In most browsers including Chrome and Firefox, the internal timer continues "ticking" while showing `alert/confirm/prompt`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO should have both:
In most browsers, including Chrome and Firefox, the internal timer continues "ticking" while showing
alert/confirm/prompt
.
@@ -208,7 +208,7 @@ Did you notice? | |||
|
|||
That's normal, because the time taken by `func`'s execution "consumes" a part of the interval. | |||
|
|||
It is possible that `func`'s execution turns out to be longer than we expected and takes more than 100ms. | |||
It is possible that `func`'s execution to be longer than we expected and take more than 100ms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disagree, leave as original
@@ -256,9 +256,9 @@ The first line "puts the call into calendar after 0ms". But the scheduler will o | |||
There are also advanced browser-related use cases of zero-delay timeout, that we'll discuss in the chapter <info:event-loop>. | |||
|
|||
````smart header="Zero delay is in fact not zero (in a browser)" | |||
In the browser, there's a limitation of how often nested timers can run. The [HTML Living Standard](https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers) says: "after five nested timers, the interval is forced to be at least 4 milliseconds.". | |||
In the browser, there's a limitation for how often nested timers can run. The [HTML Living Standard](https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers) says: "after five nested timers, the interval is forced to be at least 4 milliseconds.". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disagree
Please make the requested changes. After it, add a comment "/done". |
lines 101, 211, 259, 261, 280, 282 and 284 - improvement suggestions
line 130 - grammar fix