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