Skip to content

Commit

Permalink
runtime/system/object: add invokeNext to SC.Object
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Evans committed Dec 8, 2011
1 parent 6ff11ef commit 10a5552
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions frameworks/runtime/system/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,23 @@ SC.Object.prototype = {
return this ;
},

/**
Invokes the passed method once at the end of the current runloop,
after bindings have synchronized. This is useful for situations where
you know you need to update something, but due to the way the run loop
works, you can't actually do the update until the run loop has completed.
Note that in development mode only, the object and method that call this
method will be recorded, for help in debugging scheduled code.
@param {Function|String} method method or method name
@returns {SC.Object} receiver
*/
invokeLast: function(method) {
SC.RunLoop.currentRunLoop.invokeLast(this, method) ;
return this ;
},

/**
Invokes the passed method once at the beginning of the next runloop,
before any other methods (including events) are processed. This is useful
Expand All @@ -778,23 +795,19 @@ SC.Object.prototype = {
var obj = MyRecord.newRecord() ;
// update the collection controller's selection
MyApp.myRecordCollectionController.invokeLast( function() {
MyApp.myRecordCollectionController.invokeNext( function() {
this.set('selection', [obj]) ;
});
}
You can call invokeLast as many times as you like and the method will
only be invoked once.
Note that in development mode only, the object and method that call this
method will be recorded, for help in debugging scheduled code.
@param {Function|String} method method or method name
@returns {SC.Object} receiver
*/
invokeLast: function(method) {
SC.RunLoop.currentRunLoop.invokeLast(this, method) ;
return this ;
invokeNext: function (method) {
SC.RunLoop.currentRunLoop.invokeNext(this, method);
},

/**
Expand Down

0 comments on commit 10a5552

Please sign in to comment.