Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Add optional vuex-electron plugin (#692)
Browse files Browse the repository at this point in the history
* Sync Vuex store between all processes

* Add information about `vuex-electron` to docs
  • Loading branch information
Andrew Emelianenko authored and XanderLuciano committed Oct 23, 2018
1 parent cf53551 commit b1f069a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/en/vue_accessories.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ electron-vue comes packed with the following `vue` plugins that can be installed
* [vue-electron](https://github.com/SimulatedGREG/vue-electron) \(attach electron APIs to Vue object\)
* [vue-router](https://github.com/vuejs/vue-router) \(single page application routes\)
* [vuex](https://github.com/vuejs/vuex) \(flux-inspired application architecture\)
* [vuex-electron](https://github.com/vue-electron/vuex-electron) \(sync vuex store between all processes and instances\)

---

Expand Down Expand Up @@ -33,3 +34,8 @@ The provided project structure should feel familiar to the setup provided in the
The provided project structure is rather bare but does encourage the use of `vuex`'s module pattern to help organize your data stores. The extra `@/store/modules/index.js` let's your `vuex` store import all modules in a one-shot manner.

### [`vuex-electron`](https://github.com/vue-electron/vuex-electron)

> The easiest way to use your Vuex store between all processes (including main) and instances.
In case if your application has multiple windows, probably you would need to share the state of the application between them. Moreover, probably you would need to share the state of the app between launches or different instances. You could easily solve these two tasks by using `vuex-store`.
7 changes: 4 additions & 3 deletions meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ module.exports = {
plugins: {
type: 'checkbox',
message: 'Select which Vue plugins to install',
choices: ['axios', 'vue-electron', 'vue-router', 'vuex'],
default: ['axios', 'vue-electron', 'vue-router', 'vuex']
choices: ['axios', 'vue-electron', 'vue-router', 'vuex', 'vuex-electron'],
default: ['axios', 'vue-electron', 'vue-router', 'vuex', 'vuex-electron']
},
eslint: {
type: 'confirm',
Expand Down Expand Up @@ -148,7 +148,8 @@ module.exports = {
'axios': '^0.18.0',
'vue-electron': '^1.0.6',
'vue-router': '^3.0.1',
'vuex': '^3.0.1'
'vuex': '^3.0.1',
'vuex-electron': '^1.0.0'
}

if (Object.keys(plugins).length > 0) output += ',\n'
Expand Down
10 changes: 10 additions & 0 deletions template/src/renderer/store/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import Vue from 'vue'
import Vuex from 'vuex'

{{#isEnabled plugins 'vuex-electron'}}
import { createPersistedState, createSharedMutations } from 'vuex-electron'

{{/isEnabled}}
import modules from './modules'

Vue.use(Vuex)

export default new Vuex.Store({
modules,
{{#isEnabled plugins 'vuex-electron'}}
plugins: [
createPersistedState(),
createSharedMutations()
],
{{/isEnabled}}
strict: process.env.NODE_ENV !== 'production'
})

0 comments on commit b1f069a

Please sign in to comment.