Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix context binding in debounce and throttle functions #114

Closed
wants to merge 2 commits into from

Conversation

msssk
Copy link
Contributor

@msssk msssk commented Oct 1, 2014

@@ -4,7 +4,7 @@ define([], function(){
// summary:
// This module provide a debouncer

return function(cb, wait){
return function(cb, wait, contextObject){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflates lang.hitch/Function.prototype.bind API with other APIs. We used to do this with dojo.connect but do not do it any more.

@csnover
Copy link
Member

csnover commented Oct 1, 2014

The only change that needs to be made is the one mentioned in the comment at https://github.com/dojo/dojo/pull/114/files#r18262450, the other changes here aren’t valid

@msssk
Copy link
Contributor Author

msssk commented Oct 1, 2014

Thanks for clarifying this, @csnover. For reference, in case anyone else doesn't follow what's going on, the function that debounce returns may be called with a particular context, and we want to preserve that within setTimeout. e.g.

declare(null, {
    doSomething: debounce(function () {
        this.doSomethingElse();
    }, 250),
    doSomethingElse: function () {}
})

Any other context binding the user wants to do, as csnover mentioned, should be done with lang.hitch.

@dylans
Copy link
Member

dylans commented Oct 6, 2014

Thanks. Closed via 04101da.

@dylans dylans closed this Oct 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants