Skip to content

Commit

Permalink
fix(evbcStore): infinite recursive updates
Browse files Browse the repository at this point in the history
Closes #38
Closes #39

Signed-off-by: Lukas Mertens <git@lukas-mertens.de>

commit-id:08cc0a8d
  • Loading branch information
lukas-mertens committed Mar 14, 2024
1 parent 0e106d0 commit 7a88792
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/store/evbc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {defineStore} from 'pinia';
import {reactive, ref, watch} from 'vue';
import {reactive, ref} from 'vue';
import EVConfigModel from "@/modules/evbc/config_model";
import ConfigStageContext, {SelectionType} from "@/modules/evconf_konva/stage_context";
import {ConnectionID, ModuleInstanceID, Terminal} from "@/modules/evbc";
Expand All @@ -10,14 +10,11 @@ export const useEvbcStore = defineStore('evbc', () => {
const config_model = ref<EVConfigModel | null>(null);
const config_context = reactive(new ConfigStageContext());

// Watcher inside the store
watch(() => config_context, (configStageContext) => {
configStageContext.add_observer((ev) => {
if (ev.type === "SELECT") {
selection.value = ev.selection;
}
});
}, { deep: true });
config_context.add_observer((ev) => {
if (ev.type === "SELECT") {
selection.value = ev.selection;
}
});

function setOpenedConfig(model: EVConfigModel) {
if (config_opened.value) {
Expand Down

0 comments on commit 7a88792

Please sign in to comment.