Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Proposal: self.queueMicrotask(f) #512

Closed
Labels
@domenic

Description

@domenic

In talking with the Angular team (mostly@mhevery), there is interest in a simple low-level method for enqueuing a microtask from author code. I've heard this from a number of authors in the past. It seems simple enough and easy to add to the spec, if we can get any other implementations besides Chrome interested.

Right now authors are doing this via a number ofhacks, like creating a text node and a MutationObserver and twiddling the text node every time they want to trigger a microtask, or usingPromise.resolve().then(f) (which creates a promise object and stores any thrown errors there, instead of letting them propagate to "report an exception").

There are many use cases, which I'm sure we can assemble in depth, but let me just start with the following reasons which will hopefully be enough to convince people:

  • From an academic point of view, this is a low-level primitive and there's no reason to lock it up behind higher-level concepts like promises and mutation observers.
  • From a practical point of view, libraries very often want to guarantee asynchrony (toavoid Zalgo), without taking the overhead of a full "macro" task likesetTimeout(f, 0).

I'd like to first focus this thread on finding implementer support: if we spec this, will you implement it?After that, we can start bikeshedding the name; please don't do so beforehand.

/ccing some implementers:@hober@travisleithead@bzbarsky

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp