Last active
February 17, 2017 09:23
-
-
Save wallrat/436adf6628d3535a48f87d5e5b8407a0 to your computer and use it in GitHub Desktop.
Wrapping the six-sdk connect() to memoize sessions
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
import sdk from 'six-sdk' | |
let cachedSession | |
let cachedToken | |
export default { | |
connect: (token) => { | |
if (token === cachedToken) { | |
return cachedSession | |
} | |
cachedToken = token | |
return (cachedSession = sdk.connect(token)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment