state-management-utilities
Version:
State management utilities
29 lines (28 loc) • 1.35 kB
TypeScript
import type { HydratedEntry } from "./center";
import type { TypeStateManagerConfigs } from "./state-manager";
import { StateManager } from "./state-manager";
export declare class StoreManager<DataType extends Record<string, any>, Entities extends {
[Key in keyof Required<DataType>]: StateManager<DataType[Key]>;
}> {
protected readonly _uid: string;
protected readonly _config: StoreManagerConfigs<DataType>;
protected _initialValues: {
[Key in keyof Required<DataType>]: DataType[Key];
};
protected _KEYS: (keyof DataType)[];
protected _initializeEntity<Key extends keyof DataType>(initialValue: DataType[Key], config: TypeStateManagerConfigs<DataType[Key]>): any;
readonly entities: Entities;
constructor(initialValues: {
[Key in keyof Required<DataType>]: DataType[Key];
}, _uid?: string, _config?: StoreManagerConfigs<DataType>);
set value(value: DataType);
get value(): Required<DataType>;
update(updater: DataType | ((prev: Required<DataType>) => DataType)): this;
reset(): void;
get initialValues(): { [Key in keyof Required<DataType>]: DataType[Key]; };
fulfill(): Promise<this>;
hydrate(value: DataType): HydratedEntry;
}
export type StoreManagerConfigs<DataType> = {
[Key in keyof DataType]?: Omit<TypeStateManagerConfigs<DataType[Key]>, "uid">;
};