Skip to content

Instantly share code, notes, and snippets.

@milosdakic
Created September 26, 2017 01:25
Show Gist options
  • Save milosdakic/8f79a1e6417c6230d5095ca1dc701da0 to your computer and use it in GitHub Desktop.
Save milosdakic/8f79a1e6417c6230d5095ca1dc701da0 to your computer and use it in GitHub Desktop.
Shared Token
import Rx from 'rx-lite'
import Axios from '../../utils/axios'
const subject = new Rx.ReplaySubject(1)
export default () => {
Rx.Observable.fromPromise(Axios.get('/api/storefront/cart/gettoken'))
.take(1)
.share()
.subscribe(subject.onNext)
return subject.asObservable()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment