Skip to content

actions get surpressed without any log message #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marvinosswald opened this issue Oct 3, 2018 · 7 comments
Closed

actions get surpressed without any log message #5

marvinosswald opened this issue Oct 3, 2018 · 7 comments

Comments

@marvinosswald
Copy link

...mapActions({
        addPod: 'pods/add',
        updatePod: 'pods/update',
        removePod: 'pods/remove',
        resetPods: 'pods/reset'
      })

i'm calling the addPod Action but my action never gets hit.. if i remove this plugin from vuex it works seemless.

Please let me know if i can provide more data.

my vuex index.js

import Vue from 'vue'
import Vuex from 'vuex'

import modules from './modules'
import {createPersistedState, createSharedMutations} from 'vuex-electron'

Vue.use(Vuex)

export default new Vuex.Store({
  modules,
  strict: process.env.NODE_ENV !== 'production',
  plugins: [
    createPersistedState({
      whitelist: ['setCurrentNamespace']
    }),
    createSharedMutations()
  ]
})
@miyanokomiya
Copy link

Is it necessary for working the plugin 'createSharedMutations' to init Vuex at main process and all renderer processes?
When I did it the plugin worked, but I have no confidence that it's correct usage.

I want a sample project which teaches me how to use 'vuex-electron'.

@Ksistof
Copy link

Ksistof commented Oct 28, 2018

@miyanokomiya Could you please provide your code of main.js? I am trying to make it work with no luck. Thanks

@miyanokomiya
Copy link

miyanokomiya commented Oct 28, 2018

@Ksistof
The plugin 'createSharedMutations' seems to make the store global for all processes.
All processe have original state, but each state has the same value by 'createSharedMutations'.

If renderer processes dispach actions, the actions is cancelled in renderer processes and notify main process to do the actions.
If main process commit mutations, the mutations change state of that and notify renderer processes to do the same mutations to change each state of them.
If renderer processes commit mutations, a error occurs.

The only thing I did is to init Vuex from main process and renderer process.

src
  - main.js
  - renderderMain.js
  - store.js

main.js

import './store' // this code makes 'vuex-electron' work well

~~~ normar code to init electron app ~~~

renderderMain.js

import Vue from 'vue'
import store from './store'
import App from './App'

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
new Vue({
  components: { App },
  store,
  template: '<App/>'
}).$mount('#app')

store.js

import Vue from 'vue'
import Vuex from 'vuex'
import { createPersistedState, createSharedMutations } from 'vuex-electron'

Vue.use(Vuex)
export default new Vuex.Store({
  ~~~ state, actions etc... ~~~,
  plugins: [createPersistedState(), createSharedMutations()],
  strict: process.env.NODE_ENV !== 'production'
})

@akodkod
Copy link
Contributor

akodkod commented Nov 10, 2018

@marvinosswald @miyanokomiya @Ksistof

Hey guys,

I've added the example project and updated documentation a little bit. I'm sorry, I really missed one step in Installation guide.

In case if you are using createSharedMutations() you need to create an instance of Vuex Store in the main process. Just add such line to your main process:

import './path/to/your/store'

Also, you could check the example project:
https://github.com/vue-electron/vuex-electron-example

Let me know if you have any questions.

Have a nice day ;)

@Burtonium
Copy link

Burtonium commented Nov 12, 2018

The devs should at least write out an error message if this fails, though, and save a headache for other developers.

@marvinosswald
Copy link
Author

Solved, thanks @MrEmelianenko for the neat example !

@paramsinghvc
Copy link

Why is it closed, the issue is still there!! Just spent hours on debugging this silly thing 😤 SimulatedGREG/electron-vue#733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants