@ferm10n/vuex-electron
v1.1.0-beta.1
Published
Vuex Electron
Downloads
8
Readme
🔥 NOTE! This project is forked from the unmaintained vue-electron/vuex-electron. I forked this and changed the namespace because I see a good possibility of having my team use it and becoming a maintainer for it. If it gets traction and I get time approved to regularly work on it I might try become a maintainer of the original. Here's the changes:
- fix compilation error while installing dependencies
- rewrite in typescript, added type declaration files too
- WIP allow use without node-integration, by only requiring electron/electron-store when ipcRenderer/ipcMain is not provided
- update to work with electron 7
- support return values from the main process to the renderer when actions are dispatched
Vuex Electron
The easiest way to share your Vuex Store between all processes (including main).
Features
:star: Persisted state
:star: Shared mutations
Requirements
Installation
Installation of the Vuex Electron easy as 1-2-3.
Install package with using of yarn or npm:
yarn install vuex-electron
or
npm install vuex-electron
Include plugins in your Vuex store::
import Vue from "vue" import Vuex from "vuex" import { createPersistedState, createSharedMutations } from "vuex-electron" Vue.use(Vuex) export default new Vuex.Store({ // ... plugins: [createPersistedState(), createSharedMutations()], // ... })
In case if you enabled
createSharedMutations()
plugin you need to create an instance of store in the main process. To do it just add this line into your main process (for examplesrc/main.js
):import "./path/to/your/store"
Well done you did it! The last step is to add the star to this repo :smile:
Usage example: Vuex Electron Example
IMPORTANT
In renderer process to call actions you need to use dispatch
or mapActions
. Don't use commit
because actions fired via commit
will not be shared between processes.
Options
Available options for createPersistedState()
createPersistedState({
whitelist: ["whitelistedMutation", "anotherWhitelistedMutation"],
// or
whitelist: (mutation) => {
return true
},
// or
blacklist: ["ignoredMutation", "anotherIgnoredMutation"],
// or
blacklist: (mutation) => {
return true
},
})
Author
Andrew Emelianenko
IG: @truemelianenko