Created
May 18, 2021 04:02
-
-
Save braden-w/b5305401db0b81a51d5710fa2d6b91dc to your computer and use it in GitHub Desktop.
A method of storing and clearing timers
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 timeout = {} | |
const updateUserProfileInformation = (updateKey, updateValue) => { | |
if (signedIn.value) { | |
clearTimeout(timeout?.[updateKey]) | |
console.log("timeout :>> ", timeout) | |
console.log("payload :>> ", updateKey, updateValue) | |
timeout[updateKey] = setTimeout(async () => { | |
await updateToFirestore($fire, userProfileInformation, { | |
[updateKey]: updateValue, | |
}) | |
}, 2000) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment