feat(svelte): reset store when component unmounts

This commit is contained in:
moklick
2023-03-14 12:05:36 +01:00
parent 608768fd5b
commit cca25a792b
4 changed files with 21 additions and 2 deletions
+11 -1
View File
@@ -287,6 +287,15 @@ export function createStore(params: CreateStoreParams): SvelteFlowStore {
updateConnection(initConnectionData);
}
function reset() {
store.fitViewOnInitDone.set(false);
store.selectionRect.set(null);
store.selectionRectMode.set(null);
resetSelectedElements();
cancelConnection();
}
return {
// state
...store,
@@ -310,7 +319,8 @@ export function createStore(params: CreateStoreParams): SvelteFlowStore {
addSelectedNodes,
panBy,
updateConnection,
cancelConnection
cancelConnection,
reset
};
}
+1
View File
@@ -30,6 +30,7 @@ export type SvelteFlowStoreActions = {
panBy: (delta: XYPosition) => void;
updateConnection: (connection: Partial<ConnectionData>) => void;
cancelConnection: () => void;
reset(): void;
};
export type SvelteFlowStoreState = typeof initialStoreState & {