fix(flow): store & usevueflow types
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user