Bug 156696

Summary: Web Inspector: Fix the debounce function
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: Web InspectorAssignee: Timothy Hatcher <timothy>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch bburg: review+, timothy: commit-queue-

Timothy Hatcher
Reported 2016-04-18 07:52:04 PDT
It puts the symbol on the bound function, not the original.
Attachments
Patch (2.05 KB, patch)
2016-04-18 08:15 PDT, Timothy Hatcher
bburg: review+
timothy: commit-queue-
Radar WebKit Bug Importer
Comment 1 2016-04-18 07:52:19 PDT
Timothy Hatcher
Comment 2 2016-04-18 08:15:43 PDT
Blaze Burg
Comment 3 2016-04-18 08:53:44 PDT
Comment on attachment 276638 [details] Patch r=me Could you include a short description of how to use this function? I had to go over to underscore.js to confirm what I thought was going on.
Timothy Hatcher
Comment 4 2016-04-18 10:29:07 PDT
Joseph Pecoraro
Comment 5 2016-04-18 13:43:38 PDT
Comment on attachment 276638 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=276638&action=review > Source/WebInspectorUI/UserInterface/Base/Utilities.js:1210 > - let callback = this.bind(thisObject); > - return function() { > - clearTimeout(callback[debounceSymbol]); > + return () => { > + clearTimeout(this[debounceSymbol]); > + > let args = arguments; > - callback[debounceSymbol] = setTimeout(() => { > - callback.apply(null, args); > + this[debounceSymbol] = setTimeout(() => { > + this.apply(thisObject, args); > }, delay); > }; I don't think this works. Because the "arguments" here are not the correct arguments. Looking back at the original bug: https://bugs.webkit.org/show_bug.cgi?id=152655 Maybe this can be reduced to: value: function(delay, thisObject) { return (...args) => { clearTimeout(this[debounceSymbol]); this[debounceSymbol] = setTimeout(this.bind(thisObject), delay, ...args); } } We could add a unit-test for this.
Note You need to log in before you can comment on or make changes to this bug.