Skip to content

Instantly share code, notes, and snippets.

@rwjblue
Created October 12, 2013 21:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwjblue/6955099 to your computer and use it in GitHub Desktop.
Save rwjblue/6955099 to your computer and use it in GitHub Desktop.
Ember Run Loop Queues

The run loop in Ember starts off with three 'default' queues (sync, actions, destroy) setup here. A few additional queues (render and afterRender) are added by the ember-views package here. The ember-routing package also adds routerTransitions here.

You can see the list of run loop queues in your application along with their ordering by running Ember.run.queues in the console:

Ember.run.queues
["sync", "actions", "routerTransitions", "render", "afterRender", "destroy"]

Here is a little more detail about each queue (along with source references if available/known):

  • sync - Bindings use this queue so this method is a useful way to immediately force all bindings in the application to sync. Use this queue anytime you need any changed state to propagate throughout the app immediately without repainting the UI (which happens in the later 'render' queue added by the ember-views package). (See here for details.)
  • actions - This is the default queue and is used the most throughout the Ember codebase.
    • Used for Ember.run and Ember.run.later by default.
    • RSVP promises resolve in this queue.
  • routerTransitions - Used in router transitions to prevent unnecessary loading state if all promises resolve on the actions queue first. (See here.)
  • render - Used for rendering views after bindings have synced. All DOM element operations happen in this queue.
  • afterRender - Used for scheduling actions that occur after all view rendering (DOM operations) has occurred.
  • destroy - Used by Ember.Core.Object within the destroy function (see here) to schedule destruction to happen at the end of the run loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment