///
export interface StateHistory {
actionName: string;
state: T;
}
/**
* Store that hooks into actions
*
* Store holds all data and is the only class that should modify the data,
* anything that pulls data from the DataStore cannot modify it and should treat
* it as immutable
*/
declare class Store {
/**
* Holds our state
*/
protected state: T;
/**
* If state history is enabled, all state changes are saved here
*/
protected stateHistory: StateHistory[];
/**
* Hold our listeners, whenever the store's state changes, they will be
* notified, and sent the new state, and old state
*/
protected listeners: ((...any) => any)[];
/**
* High performance loads will only dispatch state updates on requestAnimationFrame
*/
protected highPerformance: boolean;
/**
* Used to signify if the state is dirty and we should send a notify
*/
protected dirtyState: boolean;
/**
*
*/
protected _nextState: T;
/**
* Whether or not we are in debug mode
*/
debug: boolean;
constructor();
/**
* Listen on a given event
*/
listen(callback: ((...args: any[]) => any)): void;
/**
* Return our current state
*/
getState(): T;
/**
* Ignore an event we are listening on
*/
ignore(callback: ((...args: any[]) => any)): boolean;
/**
* Change the state
*/
stateChange(actionName: string, nextState: T): T;
/**
* Clonse the current state
*/
cloneState(): T;
/**
* @deprecated use nextState
*/
newState(): T;
/**
* Return the next state (this is a WIP state that has not been sent to listeners)
*/
nextState(): T;
/**
* Sends notification of state to given listeners
*/
protected notify(oldState: T): void;
/**
* Insert an item into the given modelArray, update it if it already exists
*/
upsertItem(modelArray: any[], keyValue: any, newItem: any, overwrite?: boolean): boolean;
/**
* Get an item from a modelArray
*/
getItem(modelArray: any[], keyValue: any): any;
/**
* Remove an item from a modelArray
*/
removeItem(modelArray: any[], keyValue: any): any[] | boolean;
/**
* Pass in an array of keyValues and remove all items that match
*/
removeItems(modelArray: any[], keyValues: any[]): void;
/**
* Sanitize and valide the given object to the given schema
*/
sanitizeAndValidate(obj: any, schema: any): any;
/**
* Validate the given object to the given schema, will return an array
* of errors, or true if valid
*/
validate(obj: any, schema: any): any[] | boolean;
/**
* Sanitize the given object to a schema, also an optional parameter if
* you are sending the object as JSON, to format datetimes properly
*/
sanitize(obj: any, schema: any, json?: boolean): any;
/**
* Merge objects together
*/
merge(obj1: any, obj2: any): any;
/**
* Creates a filter sort callback to sort by a given key
*/
sortBy(key: string, dir?: string): (a: any, b: any) => number;
/**
* Formats a given number to two decimal places
*/
money(value: number): string;
/**
* Generates a UUID
*/
uuid(): string;
static string(params?: {}): {
type: string;
};
static int(params?: {}): {
type: string;
};
static double(params?: {}): {
type: string;
};
static bool(params?: {}): {
type: string;
};
static float(params?: {}): {
type: string;
};
static array(params?: {}): {
type: string;
schema: any;
};
static object(params?: {}): {
type: string;
schema: any;
};
static datetime(params?: {}): {
type: string;
schema: any;
format: string;
};
static callback(params?: {}): {
type: string;
schema: any;
};
static customType(type: any, params?: {}): {
type: any;
schema: any;
};
/**
* Sanitizes a field on an object to the given schema
*/
protected sanitizeField(field: string, obj: any, schema: any, json: boolean): any;
protected sanitizeCallback(value: any, schemaConfig: any): any;
/**
* Sanitizes a field to an integer
*/
protected sanitizeInteger(value: any, schemaConfig: any): any;
/**
* Sanitizes a field to a float
*/
protected sanitizeFloat(value: any, schemaConfig: any): any;
/**
* Sanitizes a field to a string
*/
protected sanitizeString(value: any, schemaConfig: any): any;
/**
* Sanitizes a field to a moment object
*/
protected sanitizeDateTime(value: any, schemaConfig: any, json: boolean): any;
/**
* Sanitizes a field to boolean
*/
protected sanitizeBoolean(value: any, schemaConfig: any): any;
/**
* Sanitizes an object
*/
protected sanitizeObject(value: any, schemaConfig: any, json: boolean): any;
/**
* Sanitizes an array of objects
*/
protected sanitizeArray(value: any, schemaConfig: any, json: boolean): any;
}
export default Store;