fix(core): move watcher timing to pre and sync immediately

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-18 18:53:44 +01:00
committed by Braks
parent 85d5a64d51
commit 15f73fb4d5
+2 -23
View File
@@ -27,15 +27,12 @@ export const useWatch = (
store.setElements(elements) store.setElements(elements)
nextTick(() => {
pauseStore?.resume() pauseStore?.resume()
})
} }
}, },
{ immediate }, { immediate },
) )
nextTick(() => {
pauseStore = watchPausable( pauseStore = watchPausable(
[store.nodes, store.edges, () => store.edges.value.length, () => store.nodes.value.length], [store.nodes, store.edges, () => store.edges.value.length, () => store.nodes.value.length],
([nodes, edges]) => { ([nodes, edges]) => {
@@ -49,9 +46,7 @@ export const useWatch = (
}) })
} }
}, },
{ immediate },
) )
})
onScopeDispose(() => { onScopeDispose(() => {
pauseModel?.stop() pauseModel?.stop()
@@ -76,18 +71,13 @@ export const useWatch = (
store.setNodes(nodes) store.setNodes(nodes)
nextTick(() => {
pauseStore?.resume() pauseStore?.resume()
})
} }
}, },
{ immediate }, { immediate },
) )
nextTick(() => { pauseStore = watchPausable([store.nodes, () => store.nodes.value.length], ([nodes]) => {
pauseStore = watchPausable(
[store.nodes, () => store.nodes.value.length],
([nodes]) => {
if (models.nodes?.value && Array.isArray(models.nodes.value)) { if (models.nodes?.value && Array.isArray(models.nodes.value)) {
pauseModel?.pause() pauseModel?.pause()
@@ -97,9 +87,6 @@ export const useWatch = (
pauseModel?.resume() pauseModel?.resume()
}) })
} }
},
{ immediate },
)
}) })
onScopeDispose(() => { onScopeDispose(() => {
@@ -125,18 +112,13 @@ export const useWatch = (
store.setEdges(edges) store.setEdges(edges)
nextTick(() => {
pauseStore?.resume() pauseStore?.resume()
})
} }
}, },
{ immediate }, { immediate },
) )
nextTick(() => { pauseStore = watchPausable([store.edges, () => store.edges.value.length], ([edges]) => {
pauseStore = watchPausable(
[store.edges, () => store.edges.value.length],
([edges]) => {
if (models.edges?.value && Array.isArray(models.edges.value)) { if (models.edges?.value && Array.isArray(models.edges.value)) {
pauseModel?.pause() pauseModel?.pause()
@@ -146,9 +128,6 @@ export const useWatch = (
pauseModel?.resume() pauseModel?.resume()
}) })
} }
},
{ immediate },
)
}) })
onScopeDispose(() => { onScopeDispose(() => {