mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 05:34:09 +00:00
More batch (#1468)
* batch updates in client * rearange updating logic * utilety type * guard undefinde in affectsLoaded * fix: pause state not saved to restore point
This commit is contained in:
committed by
GitHub
parent
bb1e9072fd
commit
d34280c03d
@@ -14,6 +14,18 @@ export const runtimeStore = createWithEqualityFn<RuntimeStore>(
|
||||
export const useRuntimeStore = <T>(selector: (state: RuntimeStore) => T) =>
|
||||
useStoreWithEqualityFn(runtimeStore, selector, deepCompare);
|
||||
|
||||
let batchStore: Partial<RuntimeStore> = {};
|
||||
|
||||
export function addToBatchUpdates<K extends keyof RuntimeStore>(key: K, value: RuntimeStore[K]) {
|
||||
batchStore[key] = value;
|
||||
}
|
||||
|
||||
export function flushBatchUpdates() {
|
||||
const state = runtimeStore.getState();
|
||||
runtimeStore.setState({ ...state, ...batchStore });
|
||||
batchStore = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows patching a property of the runtime store
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user