jashkenas/underscore

Run debounce() callback if browser tab is closed

h opened this issue · 1 comments

h commented

There's common problem with debounced API calls: when the user closes the browser tab, the debounced function may not have run yet. This is a frequent cause of data loss. The _.debounce() function should avoid this issue by running the trailing debounce immediately if the tab is closed prior to the trailing timeout. This should only happen while running inside a browser because it's not relevant in headless runtimes (e.g. Node.js).

Closing this for the same reason as #2984. Please take any discussion there.