vuex-electron

Vuex Electron
28,252 301
Install
npm install vuex-electron
Latest Version:1.0.3
Vue:2
License:MIT
Last Updated:May 19, 2024
Links: GitHub  ·  npm
Maintainer: emelianenko

Vuex Electron

Travis Code Climate Code Climate Code Style Prettier Made With Love

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.

  1. Install package with using of yarn or npm:

    yarn install vuex-electron
    

    or

    npm install vuex-electron
    
  2. 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()
      ],
      // ...
    })
    
  3. 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 example src/main.js):

    import './path/to/your/store'
    
  4. 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: ["whitelistedAction", "anotherWhitelistedAction"],

  // or

  whitelist: (mutation) => {
    return true
  },

  // or

  blacklist: ["ignoredAction", "anotherIgnoredAction"],

  // or

  blacklist: (mutation) => {
    return true
  }
})

Author

Andrew Emelianenko
IG: @truemelianenko

License

MIT License

Related Packages

vuex-electron-store

Persist and rehydrate the Vuex state in your Electron app

1,614 19
spyfu-vuex-helpers

Utility functions for Vuex.

2,459 9
vuex-pathify

Ridiculously simple Vuex setup + wiring

322,817 1,358
direct-vuex

Use and implement your Vuex store with TypeScript types. Compatible with the Vue...

90,286 255
undo-redo-vuex

A Vuex plugin for module namespaced undo and redo functionality. This plugin tak...

9,207 47

Version History

Version Released License
1.0.3 MIT
1.0.2 MIT
1.0.1 MIT
1.0.0 MIT
0.2.2 MIT