@statezero/core
Version:
The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate
54 lines (53 loc) • 2.15 kB
TypeScript
export class ModelStore {
constructor(modelClass: any, fetchFn: any, initialGroundTruth?: null, initialOperations?: null, options?: {});
modelClass: any;
fetchFn: any;
groundTruthArray: never[];
operationsMap: Map<any, any>;
isSyncing: boolean;
pruneThreshold: any;
modelCache: Cache;
_lastRenderedData: Map<any, any>;
renderCallbacks: Set<any>;
_unsubscribeTempPk: Function;
registerRenderCallback(callback: any): () => boolean;
/**
* Load operations from data and add them to the operations map,
* reusing existing operations from the registry if they exist
*/
_loadOperations(operationsData: any): void;
get cacheKey(): string;
onHydrated(): void;
setCache(result: any): void;
clearCache(): void;
updateCache(items: any, requestedPks: any): void;
get operations(): any[];
get pkField(): any;
addOperation(operation: any): void;
updateOperation(operation: any): boolean;
confirm(operation: any): void;
reject(operation: any): void;
setOperations(operations?: any[]): void;
setGroundTruth(groundTruth: any): void;
getGroundTruth(): never[];
get groundTruthPks(): never[];
addToGroundTruth(instances: any): void;
_filteredOperations(pks: any, operations: any): any;
_filteredGroundTruth(pks: any, groundTruthArray: any): Map<any, any>;
applyOperation(operation: any, currentInstances: any): any;
getTrimmedOperations(): any[];
getInflightOperations(): any[];
prune(): void;
/**
* Prune model instances that aren't referenced by any queryset store.
* This prevents unbounded cache growth from included nested models.
*
* @param {QuerysetStoreRegistry} querysetStoreRegistry - The registry to check for queryset references
*/
pruneUnreferencedInstances(querysetStoreRegistry: QuerysetStoreRegistry): void;
render(pks?: null, optimistic?: boolean, useCache?: boolean): any;
_renderFromCache(pks: any): any;
_renderFresh(pks?: null, optimistic?: boolean): any[];
sync(pks?: null): Promise<void>;
}
import { Cache } from '../cache/cache.js';