fix(flow): store & usevueflow types

This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent c1594b0071
commit 95bc46e616
9 changed files with 25 additions and 32 deletions
+1 -1
View File
@@ -47,4 +47,4 @@ const bind = (emit: EmitFunc, hooks: FlowHooks) => {
}
}
export default (hooks: FlowHooks, emit: EmitFunc) => bind(emit, hooks)
export default (emit: EmitFunc, hooks: FlowHooks) => bind(emit, hooks)
+5 -7
View File
@@ -1,7 +1,7 @@
import useState from './state'
import useActions from './actions'
import useGetters from './getters'
import { FlowHooksOn, FlowOptions, State, Store } from '~/types'
import { FlowHook, FlowHooksOn, FlowOptions, Store, State } from '~/types'
export default (preloadedState?: FlowOptions): Store => {
const state: State = useState(preloadedState)
@@ -11,7 +11,7 @@ export default (preloadedState?: FlowOptions): Store => {
const hooksOn: FlowHooksOn = <any>{}
Object.entries(reactiveState.hooks).forEach(([n, h]) => {
const name = `on${n.charAt(0).toUpperCase() + n.slice(1)}`
hooksOn[<keyof FlowHooksOn>name] = h.on as any
hooksOn[<keyof FlowHooksOn>name] = h.on as FlowHook['on']
})
actions.setState(reactiveState)
if (preloadedState) {
@@ -20,13 +20,11 @@ export default (preloadedState?: FlowOptions): Store => {
if (preloadedState.edges) actions.setEdges(preloadedState.edges)
}
return {
return reactive({
state: reactiveState,
actions,
getters,
hooksOn,
...hooksOn,
...toRefs(reactiveState),
...getters,
...actions,
} as unknown as Store
})
}