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

doc: fix recommendation of setImmediate() over process.nextTick() #30801

Closed
davalapar opened this issue Dec 5, 2019 · 6 comments · Fixed by nodejs/nodejs.org#2827
Closed
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Comments

@davalapar
Copy link

Is your feature request related to a problem? Please describe.

On this url:

At the process.nextTick() section, it says:

We recommend developers use setImmediate() in all cases because it's easier to reason about (and it leads to code that's compatible with a wider variety of environments, like browser JS.)

But this is untrue since setImmediate() isn't supported in "wider variety of environments". Only supported in Edge & IE, but not Chrome, Firefox, Safari (on both desktop and mobile platforms).

Describe the solution you'd like

  • remove that last phrase "(and it leads to code that's compatible with a wider variety of environments, like browser JS.)"?

Describe alternatives you've considered

  • I think setTimeout and window.requestAnimationFrame are the nearest alternatives for setImmediate for the browser, but I don't know how to phrase it yet
@tniessen tniessen added doc Issues and PRs related to the documentations. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. labels Dec 5, 2019
@Fishrock123
Copy link
Contributor

That phrase should probably be removed.

If we wanted compatibility notes, setTimeout(1, ...) works in most cases in the browser where you'd want a setImmediate, and Promise.resolve().then(...) works as a counterpart to process.nextTick(...) (and also works in node, but you should avoid ever doing that in node).

@Fishrock123 Fishrock123 added the good first issue Issues that are suitable for first-time contributors. label Dec 13, 2019
@devsnek
Copy link
Member

devsnek commented Dec 13, 2019

queueMicrotask too.

@szhigunov
Copy link

I would like to start with that.

@navin1551
Copy link

Hi, is this still open to work on?

@szhigunov
Copy link

Hi, is this still open to work on?

Hi, I'm working on that issue now.

szhigunov added a commit to szhigunov/nodejs.org that referenced this issue Dec 16, 2019
szhigunov added a commit to szhigunov/nodejs.org that referenced this issue Dec 19, 2019
@szhigunov
Copy link

szhigunov commented Dec 19, 2019

@Fishrock123 I created a PR where I removed that phrase. Could I somehow improve that section?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants