Last active
July 31, 2019 13:30
-
-
Save abishekrsrikaanth/e20f8fa19e9187c31b1ecbd4f2f521f9 to your computer and use it in GitHub Desktop.
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
import Vue from 'vue'; | |
import Auth from '../mixins/user-auth'; | |
import makeUserStore from '../store/user'; | |
new Vue({ | |
mixins: [Auth], | |
el: '.auth-wrapper', | |
store: makeUserStore(), | |
async mounted() { | |
let user = await this.__getUser(); | |
this.$store.commit('setUser', user.data); | |
} | |
}); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<!-- begin::Head --> | |
<head> | |
<meta charset="utf-8"/> | |
</head> | |
<body> | |
<div class='auth-wrapper'></div> | |
<div class='product-wrapper'>@{{userObject.id}}</div> | |
<script src="{{mix('js/auth.js')}}"></script> | |
<script src="{{mix('js/product.js')}}"></script> | |
</body | |
</html> | |
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
import Vue from 'vue'; | |
import Request from 'greenlyst-ui/src/mixins/request'; | |
import makeUserStore from '../../../store/user'; | |
import {mapGetters} from 'vuex'; | |
new Vue({ | |
el: '.product-wrapper', | |
store: makeUserStore(), | |
computed: { | |
...mapGetters(['userObject']) | |
} | |
}); |
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
import Vuex from 'vuex'; | |
export default function () { | |
return new Vuex.Store({ | |
state: { | |
user: {} | |
}, | |
getters: { | |
userObject: state => { | |
return state.user; | |
} | |
}, | |
mutations: { | |
setUser(state, userObj) { | |
state.user = userObj; | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment