Created
September 27, 2018 12:36
-
-
Save barisere/23747693bbbb95caeff73e6abeed583e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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