Skip to content

Instantly share code, notes, and snippets.

@wallrat
Last active February 17, 2017 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wallrat/436adf6628d3535a48f87d5e5b8407a0 to your computer and use it in GitHub Desktop.
Save wallrat/436adf6628d3535a48f87d5e5b8407a0 to your computer and use it in GitHub Desktop.
Wrapping the six-sdk connect() to memoize sessions
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