syncbasestore
Version:
Lightweight reactive store with built-in filtering and async state handling
35 lines (34 loc) • 924 B
TypeScript
export type Listener<T> = (state: T) => void;
export type FilterFunction<T> = (state: T) => T;
export type FilterShape<T> = Partial<T>;
export type FilterDefinition<T> = FilterFunction<T> | (new () => Partial<T>);
export type FlexibleFilter<T> = {
filterDef?: FilterDefinition<T>;
filterValue?: FilterShape<T>;
};
export type SyncMergeResult<T1, T2, R = undefined> = R extends undefined ? {
data1: T1;
data2: T2;
} : {
data1: T1;
data2: T2;
result: R;
};
export type FieldStatus = {
value: any;
status: 'idle' | 'isError' | 'isSuccess' | 'isWarning';
message?: string;
};
export type FormState<T> = {
[K in keyof T]: FieldStatus;
};
export type Status = 'idle' | 'error' | 'success' | 'warning';
export interface FieldState<T> {
valueField: T;
status: Status;
message?: string;
}
export type Validator<T> = (value: T) => {
status: Status;
message?: string;
};