Vuex Typescript is there a way to get types for _actions
up vote
0
down vote
favorite
I have written a vuex plugin which enables multiple stores to refresh if one specific store state have changed. All is working well, but I just want to find out is there a way to get type definition for Store._actions. You will see in my code I was forced to use any. RootState is an object with all my vuex store modules
const OnShopChangePlugin = (store: Store<RootState>) =>
store.watch(
state => state.shops.activeShopToken,
(val, oldVal) =>
// Don't do anything on init state
if (!oldVal) return;
for (let state in store.state)
const action = `$state/refresh`;
// If the store does not have an refresh action ignore
if ((store as any)._actions[action]) store.dispatch(`$state/refresh`);
);
;
typescript vuejs2 vuex vuex-modules
add a comment |
up vote
0
down vote
favorite
I have written a vuex plugin which enables multiple stores to refresh if one specific store state have changed. All is working well, but I just want to find out is there a way to get type definition for Store._actions. You will see in my code I was forced to use any. RootState is an object with all my vuex store modules
const OnShopChangePlugin = (store: Store<RootState>) =>
store.watch(
state => state.shops.activeShopToken,
(val, oldVal) =>
// Don't do anything on init state
if (!oldVal) return;
for (let state in store.state)
const action = `$state/refresh`;
// If the store does not have an refresh action ignore
if ((store as any)._actions[action]) store.dispatch(`$state/refresh`);
);
;
typescript vuejs2 vuex vuex-modules
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have written a vuex plugin which enables multiple stores to refresh if one specific store state have changed. All is working well, but I just want to find out is there a way to get type definition for Store._actions. You will see in my code I was forced to use any. RootState is an object with all my vuex store modules
const OnShopChangePlugin = (store: Store<RootState>) =>
store.watch(
state => state.shops.activeShopToken,
(val, oldVal) =>
// Don't do anything on init state
if (!oldVal) return;
for (let state in store.state)
const action = `$state/refresh`;
// If the store does not have an refresh action ignore
if ((store as any)._actions[action]) store.dispatch(`$state/refresh`);
);
;
typescript vuejs2 vuex vuex-modules
I have written a vuex plugin which enables multiple stores to refresh if one specific store state have changed. All is working well, but I just want to find out is there a way to get type definition for Store._actions. You will see in my code I was forced to use any. RootState is an object with all my vuex store modules
const OnShopChangePlugin = (store: Store<RootState>) =>
store.watch(
state => state.shops.activeShopToken,
(val, oldVal) =>
// Don't do anything on init state
if (!oldVal) return;
for (let state in store.state)
const action = `$state/refresh`;
// If the store does not have an refresh action ignore
if ((store as any)._actions[action]) store.dispatch(`$state/refresh`);
);
;
typescript vuejs2 vuex vuex-modules
typescript vuejs2 vuex vuex-modules
asked Nov 9 at 22:44
Jeremy Walters
37018
37018
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234210%2fvuex-typescript-is-there-a-way-to-get-types-for-actions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown