Upload
rizwan-reza
View
189
Download
2
Tags:
Embed Size (px)
Citation preview
“the run loop is a mechanism that Ember.js uses to group, coordinate, and execute events, key-value notifications,
and timers within your application.”From Ember.js in Action
ActionsSync DestroyAfterRenderRender
AfterRender queue is a good place to initialize jQuery plugins on elements
added by the Render queue
Sync Actions Render AfterRender Destroy
{ 3 isCompleted Events3 checked events3 remainingFormatted3 markAllDone updates
{ 3 checkboxes1 change to status1 change to “Mark all as done”
RenderActionsSync AfterRender Destroy
$.post(‘/post_cc’, success: function(e) {
Ember.run(function() { this.store.createRecord('user', { cardId: e.data.customerId, planId: 'pro' }); });
});
Executes code immediately by reusing/starting run loop
Ember.run.next(function () {
this.set(‘flash’, “Hello world”);
})
Executes code in the next available run loop
Ember.run.later(function () {
this.set(‘flash’, “Hello world”);
}, 1000)
Executes code in the next available run loop after 1s
Ember.run.schedule('afterRender', this, function () {
this.$().tooltip();
});
Schedules in the “afterRender” queue
Schedules once in the “afterRender” queue
Ember.run.scheduleOnce('afterRender', this, function () {
this.$().tooltip();
});
https://github.com/eoinkelly/ember-runloop-handbook
Ember runloop handbook