B
B
BonBon Slick2019-10-17 15:12:14
Vue.js
BonBon Slick, 2019-10-17 15:12:14

Can action be assigned as a closure to a variable for multiple call from .js?

import store                                     from '@/store';
export default function (to, from, next) {
    const updateUrl = store._actions[`namespace`];

    updateUrl.dispatch(`namespace`, {mewUrl: 'California'});

Will throw an updateUrl.dispatch is not a function error .
const module = 'some_really_very_long_namespace_for_moduloe'
const action= 'some_really_very_long_namespace_for__action'
 store._actions[module ].dispatch(action, {mewUrl: 'California'}); 
 store._actions[module ].dispatch(action, {mewUrl: 'California'}); 
 store._actions[module ].dispatch(action, {mewUrl: 'California'});

Gryaznova, I would like something like this if possible:
const store_action= store._actions[module ]
const action_namespace= 'some_really_very_long_namespace_for__action'
 store_action.dispatch(action_namespace, {mewUrl: 'California'}); 
 store_action.dispatch(action_namespace, {mewUrl: 'California'}); 
 store_action.dispatch(action_namespace, {mewUrl: 'California'});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Levchenko, 2019-11-01
@nuykon

store.dispatch('module/item', data).then(() => console.log('first call'));
store.dispatch('module/item', data).then(() => console.log('second call'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question