Created
May 5, 2015 21:10
-
-
Save runspired/a3dc4ddd1af7688a9bb8 to your computer and use it in GitHub Desktop.
Debounced and Throttle computed properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.computed.debounce = function debouncedProperty() { | |
var args = [].slice.apply(arguments); | |
var bounce = args.pop(); | |
var method = args.pop(); | |
var __value = null; | |
var methodFn = function() { | |
__value = method.call(this); | |
}; | |
args.push(function() { | |
Ember.run.debounce(this, methodFn, bounce); | |
return __value; | |
}); | |
return Ember.computed.apply(this, args); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.computed.throttle = function throttledProperty() { | |
var args = [].slice.apply(arguments); | |
var bounce = args.pop(); | |
var method = args.pop(); | |
var __value = null; | |
var methodFn = function() { | |
__value = method.call(this); | |
}; | |
args.push(function() { | |
Ember.run.throttle(this, methodFn, bounce); | |
return __value; | |
}); | |
return Ember.computed.apply(this, args); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment