Created
February 17, 2018 14:29
-
-
Save danielschmitz/f5f660d4e3312ec27ac595c6c24b856a to your computer and use it in GitHub Desktop.
Implementação genérica do store sem Vuex
This file contains hidden or 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
const store = { | |
_username: '', | |
_email: '', | |
_token: '', | |
isLogged () { | |
return this.token | |
}, | |
set username (str) { | |
this._username = str | |
localStorage.setItem('username',str) | |
}, | |
get username () { | |
return this._username || localStorage.getItem('username') | |
}, | |
set email (str) { | |
this._email = str | |
localStorage.setItem('email',str) | |
}, | |
get email () { | |
return this._email || localStorage.getItem('email') | |
}, | |
set token (str) { | |
this._token = str | |
localStorage.setItem('token',str) | |
}, | |
get token () { | |
return this._token || localStorage.getItem('token') | |
} | |
} | |
export default store; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment