-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.ts
30 lines (27 loc) · 968 Bytes
/
script.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { defineComponent, ref } from 'vue'
import { useNamespacedHelpers, useGetter, useAction } from '@/store/typed-helpers'
import * as moduleA from '@/store/modules/a'
import * as moduleB from '@/store/modules/b'
export default defineComponent({
setup () {
const a = useGetter(moduleA.COUNT) // ComputedRef<number>
const increaseOrReset = useAction(moduleA.INCREASE_OR_RESET) // (payload: {n: number, max: number}) => Promise<void>
const { useGetter: useBGetter, useMutation: useBMutation } = useNamespacedHelpers('b')
const b = useBGetter(moduleB.COUNT) // ComputedRef<number>
const resetB = useBMutation(moduleB.RESET) // (n: number) => void
const updateB = (e: InputEvent) => {
resetB(+(e.target as HTMLInputElement)?.value || 0)
}
const step = ref(5)
const doIt = () => {
increaseOrReset({n: step.value, max: b.value})
}
return {
a,
step,
b,
updateB,
doIt,
}
}
})