Skip to content

Add a 'nextTick' function to dart:core #3260

Closed
@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


If you want to defer execution of some function to a later turn of the event queue, you have to use Timer (from dart:io) on the VM and window.setTimeout (from dart:html) in the browser.

Now there is a bug to move Timer from dart:io to dart:core (and I think this should definitely be done), but using timer with zero timeout for deferring execution is quite inconvenient. I suggest to add a function like 'nextTick' to dart:core, modeled after Node.js's API (see http://nodejs.org/api/process.html#process_process_nexttick_callback).

  1. It's more convenient.
  2. The API would be the same in both environments.
  3. As Node guys point out, it can be implemented much more efficiently (which apparently only applies to the VM, it would probably still be compiled to window.setTimeout for the browser).

I'm not exactly sure about the name, maybe 'deferExecution' or 'nextTurn' would be better, but I'll leave this decision up to you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions