feat(store, flow)!: Add apply changes handlers
* flow will not update changes unless a handler to apply changes is passed * a default handler is available in the useVueFlow composable * removeElements export removed
This commit is contained in:
+8
-1
@@ -2,9 +2,10 @@ import { getCurrentInstance } from 'vue'
|
||||
import useState, { initialState } from './state'
|
||||
import useActions from './actions'
|
||||
import useGetters from './getters'
|
||||
import { FlowExportObject, FlowHooksOn, FlowOptions, FlowState, FlowStore, Store } from '~/types'
|
||||
import { EmitFunc, FlowExportObject, FlowHooksOn, FlowOptions, FlowState, FlowStore, Store } from '~/types'
|
||||
import { StoreSymbol } from '~/context'
|
||||
import { onLoadToObject } from '~/utils'
|
||||
import { useHooks, useStore } from '~/store/index'
|
||||
|
||||
const useFlowStore = (id: string, preloadedState: FlowState): Store => {
|
||||
const state = reactive(useState(preloadedState))
|
||||
@@ -61,6 +62,12 @@ export const createStore = (options?: FlowOptions) => {
|
||||
return store
|
||||
}
|
||||
|
||||
export const initFlow = (emit: EmitFunc, id?: string): FlowStore => {
|
||||
const store = useStore({ id })
|
||||
useHooks(store, emit)
|
||||
return store
|
||||
}
|
||||
|
||||
export default (options?: FlowOptions): FlowStore => {
|
||||
const currentInstance = getCurrentInstance()
|
||||
let store = currentInstance ? inject(StoreSymbol, undefined) : false
|
||||
|
||||
Reference in New Issue
Block a user