-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Yoonit-Labs/feature/plugin-store
Feature/plugin store
- Loading branch information
Showing
4 changed files
with
100 additions
and
13 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { store } from './yoox' | ||
import { VueInstall } from "./plugins/vue" | ||
import { VueNextInstall } from './plugins/vue3' | ||
|
||
export default { store } | ||
export default { store, VueInstall, VueNextInstall } | ||
|
||
export { store } | ||
export { store, VueInstall, VueNextInstall } |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
export const VueNextInstall = { | ||
install: (app, storeInstance) => { | ||
app.mixin({ | ||
data () { | ||
return { | ||
localState: {}, | ||
__Yoox: undefined | ||
} | ||
}, | ||
created () { | ||
/** | ||
* Observe to update yoox and state on changes | ||
*/ | ||
storeInstance.observe((state) => { | ||
this.localState = { ...state } | ||
this.__Yoox = { ...storeInstance } | ||
}) | ||
}, | ||
computed: { | ||
/** | ||
* Returns local state with vue reactivity | ||
* @returns {{}|*} | ||
*/ | ||
state () { | ||
return this.localState | ||
} | ||
}, // computed | ||
methods: { | ||
/** | ||
* Returns the get method of a given get name | ||
* @param payload | ||
* @returns {*} | ||
*/ | ||
get (payload) { | ||
return this.__Yoox.get(payload) | ||
}, | ||
|
||
/** | ||
* Returns the mix method of a given name | ||
* @param action | ||
* @param payload | ||
* @returns {*} | ||
*/ | ||
mix (action, payload) { | ||
return this.__Yoox.mix(action, payload) | ||
}, | ||
|
||
/** | ||
* Update yoox according to action name and payload | ||
* @param action | ||
* @param payload | ||
* @returns {*} | ||
*/ | ||
set (action, payload) { | ||
return this.__Yoox.set(action, payload) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
export default VueNextInstall |