Last active
March 23, 2019 18:11
-
-
Save Wicker25/2a7ade92ee31dbd061d9d96b0570c456 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
import { observable } from 'mobx'; | |
import { withStateTransition, stateTransition } from './StateTransition'; | |
@withStateTransition | |
export class SessionStore { | |
constructor() {} | |
@observable accessToken = null; | |
@observable user = null; | |
@stateTransition('loading', 'idle') | |
async logInByAccessToken(accessToken) { | |
await this._setAccessToken(accessToken); | |
await this._fetchUser(); | |
} | |
@stateTransition('loading', 'idle') | |
async logInWithFacebookAccessToken(facebookAccessToken) { | |
const response = await axios.get(SMUGL_API_FACEBOOK_TOKEN_CALLBACK, { | |
params: { | |
access_token: facebookAccessToken | |
} | |
}); | |
await this._setAccessToken(response.data.content.token); | |
await this._fetchUser(); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment