Open alphapapa opened 6 years ago
Hi! This looks like a useful function, but it doesn't quite fit the dash-theme. I'd suggest making a separate open source lib with perhaps throttle and debounce in it. :)
Maybe I'm just conflating things, but for some reason I had the impression that something like this was already baked into Emacs (though perhaps as part of some specific package, rather than as a general-purpose function). Maybe I'm thinking of progress reporters, or timers, or url.el
, I don't know. And all my searches are coming up dry. So feel free to ignore this comment. :)
I was browsing the CL Serapeum library and came across its throttle function. It seems complementary to
dash-functional
. I have a function in my Emacs config that I would like to throttle (it plays a notification sound when I get messages in matrix-client; I add it as advice to the built-in notification function), and this works well What do you think?Called like:
It could also be de-throttled with a
-throttle-restore
function that restores the original definition.Some of this code is borrowed from Chris Wellons'
memoize
package.