From e2f3da8e1bf6a03f042a3bb115adcd55c27fd81b Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 27 May 2022 20:21:48 +0200 Subject: [PATCH] refactor(vue-flow)!: remove reactive options --- .../vue-flow/src/composables/useVueFlow.ts | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/vue-flow/src/composables/useVueFlow.ts b/packages/vue-flow/src/composables/useVueFlow.ts index 028e41ee..659edd25 100644 --- a/packages/vue-flow/src/composables/useVueFlow.ts +++ b/packages/vue-flow/src/composables/useVueFlow.ts @@ -1,5 +1,4 @@ import type { EffectScope } from 'vue' -import type { MaybeRef } from '@vueuse/core' import type { FlowOptions, FlowProps, State, VueFlowStore } from '~/types' import { VueFlow } from '~/context' import { useActions, useGetters, useState } from '~/store' @@ -80,16 +79,13 @@ export class Storage { type Injection = VueFlowStore | null | undefined type Scope = (EffectScope & { vueFlowId: string }) | undefined -type Options = { [key in keyof FlowProps]: MaybeRef } - -export default (options?: Options): VueFlowStore => { - const reactiveOptions = options ? reactive(options) : undefined +export default (options?: FlowProps): VueFlowStore => { const storage = Storage.getInstance() const scope = getCurrentScope() as Scope - const id = reactiveOptions?.id + const id = options?.id const vueFlowId = scope?.vueFlowId || id let vueFlow: Injection @@ -119,24 +115,14 @@ export default (options?: Options): VueFlowStore => { if (!vueFlow || (vueFlow && id && id !== vueFlow.id)) { const name = id ?? storage.getId() - vueFlow = storage.create(name, reactiveOptions) + vueFlow = storage.create(name, options) if (scope) { scope.vueFlowId = name - - onBeforeMount(() => { - if (reactiveOptions) { - scope.run(() => { - watch(reactiveOptions, (opts) => { - vueFlow?.setState(opts) - }) - }) - } - }) } } else { // if composable was called with additional options after initialization, overwrite state with the options values - if (reactiveOptions) vueFlow.setState(reactiveOptions) + if (options) vueFlow.setState(options) } /**