vue-wait icon indicating copy to clipboard operation
vue-wait copied to clipboard

[Bug Report] `[vuex] unknown action type: wait/start` occurred on Vue TypeScript

Open runyasak opened this issue 5 years ago • 4 comments

Step to reproduce

Using store.dispatch('wait/start', 'app loading', { root: true }) or wait/end on router.beforeEach in Vue TypeScript project.

However, it is working fine on Vue with CommonJS project.

Expected Behavior

It should be worked without any error or warning.

Actual Behavior

There have error for unknown action type.

[vuex] unknown action type: wait/start

Environment

  • vue: 2.6.11
  • vue-wait: 1.4.8
  • typescript: 3.8.3

runyasak avatar Jul 26 '20 16:07 runyasak

Same problem

faenir avatar Oct 20 '20 20:10 faenir

Same issue, but seems to work otherwise. Any workaround?

kenzik avatar Feb 09 '21 13:02 kenzik

I think it is happening because when the dispatch happens, the wait store has not yet been registered, as of now I just added this line

if (this.hasModule('wait'))
    dispatch('wait/start', 'getCartItems', { root: true })

to remove the error

bhaskar-nair2 avatar Apr 12 '21 08:04 bhaskar-nair2

@bhaskar-nair2 i have another solution

@faenir @kenzik @runyasak

guys you can try to install vue-wait as a plugin

for example create file src/plugins/vue-wait.js and configure it like u wish

import { createVueWait } from 'vue-wait';

const vueWait = createVueWait({
    useVuex: true,
    vuexModuleName: 'wait',
    registerComponent: true,
    componentName: 'v-wait',
    registerDirective: true,
    directiveName: 'wait'
});

export default vueWait;

and after that you can import and use it in main.js file

import store from './store';
import { createApp } from 'vue';
import vueWait from './plugins/vue-wait';

import App from './App.vue';

const app = createApp(App);

app.use(store);
app.use(vueWait);

app.mount('#app');

mesa4 avatar Nov 18 '21 09:11 mesa4