mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
flush autosave on unload (#473)
This commit is contained in:
parent
37e082fcdc
commit
d44c4ca2d8
2 changed files with 15 additions and 1 deletions
|
@ -57,10 +57,17 @@ export function debounce<T extends any[]>(
|
|||
timeout: number
|
||||
) {
|
||||
let handle = 0;
|
||||
return (...args: T) => {
|
||||
let lastArgs: T;
|
||||
const ret = (...args: T) => {
|
||||
lastArgs = args;
|
||||
clearTimeout(handle);
|
||||
handle = window.setTimeout(() => fn(...args), timeout);
|
||||
};
|
||||
ret.flush = () => {
|
||||
clearTimeout(handle);
|
||||
fn(...lastArgs);
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function selectNode(node: Element) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue