Skip to content

Commit 7e061d1

Browse files
committed
fix overmind config
1 parent d0d040f commit 7e061d1

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/components/SimpleCounter.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default defineComponent({
2323
setup() {
2424
const state = useOvermind.state();
2525
const actions = useOvermind.actions();
26+
2627
return { state, actions };
2728
},
2829
});

src/overmind/index.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
import { IConfig, IContext } from "overmind";
1+
import * as actions from "./actions";
2+
3+
import { IConfig, IContext, IOnInitialize } from "overmind";
4+
5+
import { createHooks } from "overmind-vue/vue3";
6+
import { state } from "./state";
27

38
export const config = {
49
state,
510
actions,
611
};
712

13+
// Due to circular typing we have to define an
14+
// explicit typing of state, actions and effects since
15+
// TS 3.9
816
export type Config = IConfig<{
917
state: typeof config.state;
1018
actions: typeof config.actions;
19+
// effects: typeof config.effects;
1120
}>;
1221

13-
import * as actions from "./actions";
14-
15-
import { createHooks } from "overmind-vue/vue3";
16-
import state from "./state";
22+
export type OnInitialize = IOnInitialize<Config>;
1723

1824
export type Context = IContext<Config>;
1925

20-
export const useOvermind = createHooks();
26+
// Used with derived
27+
export type RootState = Context["state"];
28+
29+
export const useOvermind = createHooks<Config>();

src/overmind/state.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ type State = {
22
counter: number;
33
};
44

5-
const state: State = {
5+
export const state: State = {
66
counter: 0,
77
};
8-
9-
export default state;

0 commit comments

Comments
 (0)