Skip to content

Commit 8b2d584

Browse files
feat(overmind-vue): pass callback to other hooks as well
1 parent f674c8b commit 8b2d584

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

packages/node_modules/overmind-vue/src/index.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,30 @@ export function createStateHook<Config extends IConfiguration>(): StateHook<Conf
274274
}) as any
275275
}
276276

277-
export function createActionsHook<Config extends IConfiguration>() {
278-
return (): Overmind<Config>["actions"] => {
277+
export interface ActionsHook<Config extends IConfiguration> {
278+
(): Ref<Overmind<Config>["actions"]>;
279+
<CB extends (actions: Overmind<Config>["actions"]) => object>(cb: CB): CB extends (actions: Overmind<Config>["actions"]) => infer O ? O extends object ? Ref<O> : never : never;
280+
}
281+
282+
export function createActionsHook<Config extends IConfiguration>(): ActionsHook<Config> {
283+
return ((cb?: any): Overmind<Config>["actions"] => {
279284
const overmindInstance = inject<any>('overmind')
280285

281-
return overmindInstance.actions
282-
}
286+
return cb ? cb(overmindInstance.actions) : overmindInstance.actions
287+
}) as any
283288
}
284289

285-
export function createEffectsHook<Config extends IConfiguration>() {
286-
return (): Overmind<Config>["effects"] => {
290+
export interface EffectsHook<Config extends IConfiguration> {
291+
(): Ref<Overmind<Config>["effects"]>;
292+
<CB extends (effects: Overmind<Config>["effects"]) => object>(cb: CB): CB extends (effects: Overmind<Config>["effects"]) => infer O ? O extends object ? Ref<O> : never : never;
293+
}
294+
295+
export function createEffectsHook<Config extends IConfiguration>(): EffectsHook<Config> {
296+
return ((cb?: any): Overmind<Config>["effects"] => {
287297
const overmindInstance = inject<any>('overmind')
288298

289-
return overmindInstance.effects
290-
}
299+
return cb ? cb(overmindInstance.effects) : overmindInstance.effects
300+
}) as any
291301
}
292302

293303
export function createReactionHook<Config extends IConfiguration>() {

packages/node_modules/overmind/src/internalTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type NestedPartial<T> = T extends Function
2020
export type Options = {
2121
delimiter?: string
2222
name?: string
23+
devEnv?: string
2324
devtools?: string | boolean
2425
logProxies?: boolean
2526
hotReloading?: boolean

0 commit comments

Comments
 (0)