refactor(store): connection data

This commit is contained in:
moklick
2023-06-05 00:02:07 +02:00
parent 1dab08f36e
commit 45f51e96b1
29 changed files with 527 additions and 879 deletions
+7 -5
View File
@@ -7,7 +7,8 @@ import {
type ViewportHelperFunctionOptions,
type Connection,
type XYPosition,
type CoordinateExtent
type CoordinateExtent,
type UpdateConnection
} from '@reactflow/system';
import {
createMarkerIds,
@@ -304,21 +305,22 @@ export function createStore(params: CreateStoreParams): SvelteFlowStore {
return transformChanged;
}
function updateConnection(connectionUpdate: Partial<ConnectionData> | null) {
const updateConnection: UpdateConnection = (update) => {
const currentConnectionData = get(store.connection);
const nextConnectionData = currentConnectionData
? {
...initConnectionData,
...currentConnectionData,
...connectionUpdate
...update
}
: {
...initConnectionData,
...connectionUpdate
...update
};
store.connection.set(nextConnectionData);
}
};
function cancelConnection() {
updateConnection(initConnectionData);