Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barisere/23747693bbbb95caeff73e6abeed583e to your computer and use it in GitHub Desktop.
Save barisere/23747693bbbb95caeff73e6abeed583e to your computer and use it in GitHub Desktop.
const deleteRequestMap = new Map<string, number>();
const deleteResourceOnTimeout = (id: string, delay: number) => setTimeout(() => {
console.info(`Deleting ${id}`);
// actually delete id
deleteRequestMap.delete(id);
}, delay);
const cancelDeleteResource = (id: string) => {
clearTimeout(deleteRequestMap.get(id));
return deleteRequestMap.delete(id);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment