Skip to content

Access store from Electron main process #15

Answered by BetaHuhn
BetaHuhn asked this question in Ideas
Discussion options

You must be logged in to vote

I implemented this in the form of ipc mode in v1.3.0:

Enable ipc mode:

PersistedState.create({
	ipc: true
})

Then in the Electron main process:

import PersistedState from 'vuex-electron-store'

const store = PersistedState.getStoreFromRenderer()

// Commit a mutation
store.commit(type, payload)

// Dispatch an action
store.dispatch(action, payload)

// Get the current Vuex State
const state = await store.getState()

This way you can change the state with mutations and also dispatch actions to do other things.

Replies: 1 comment

Comment options

BetaHuhn
Jun 8, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by BetaHuhn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
enhancement New feature or request
1 participant