-
-
Save brigand/e21a16edaad24673bbeef810ed346634 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 manager = { | |
counter: 1, | |
user: null, | |
pass: null, | |
receiveCreds(user, pass) { | |
manager.user = user; | |
manager.pass = pass; | |
// increment counter | |
manager.counter += 1; | |
// store a SNAPSHOT of the counter, which | |
// can be used inside the closures | |
const counter = manager.counter; | |
setTimeout(() => { | |
if (cred.counter !== counter) { | |
// receiveCreds has been called again, | |
// which caused the counter to increment | |
return; | |
} | |
clearCredentials(); | |
}, ONE_HOUR); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment