-
Notifications
You must be signed in to change notification settings - Fork 38
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
debounce #11
Comments
Taking a stab at this tonight... |
The more I look at this, the more I think it's not a practical function to use in CFML. My implementation was starting to look like this:
It's not finished yet, but it's got me thinking about asynchronicity. When you call _.debounce() you'll get back a function that essentially sets a timer (in JS: However, CF Threads can only access shared scopes until the thread from which they were spawned completes, so we can't always count on being able to look for a should-cancel flag there. In addition, it limits the ability of the callback to do useful things with those shared scopes. I think this would be ok if threads worked like closures, but I'm not sure that they do. I'm kind of at an impasse. Any thoughts? |
I did some more reading on threads and came up with this:
I'm still concerned it will have limited utility because the callback is called from within a thread, but this may be as close as we'll get. |
Does that work? I've had problems with accessing var-scoped variables from within a thread. One thing I'd like to do is implement I'm not as concerned about the actual utility of the function as I am about trying to match the logic from Underscore.js. I figure that eventually there might be someone out there who wants to do this exact thing (even though I can't think of why). |
I haven't tried it yet. :) |
The only way I've been able to get it to work is by assigning the variable to the variables scope, which sucks. I haven't tried the request (or session?) scopes though. |
Here it comes... ;) |
Debounce was added by: bd9ff52 |
http://underscorejs.org/#debounce
The text was updated successfully, but these errors were encountered: