ngx-base-state
Version:
Base classes for creation state service via Rxjs observable
50 lines (49 loc) • 1.53 kB
TypeScript
import { Observable } from 'rxjs';
import { BaseState } from './base.state';
/**
* @class
* @classdes Record state class. Used for save state with Record type.
*/
export declare abstract class RecordState<TKey extends string, TValue> extends BaseState<Record<TKey, TValue>> {
/**
* Get all `keys` of your `Record` object state.
* @public
*/
get keys(): TKey[];
/**
* Get all `values` of your `Record` object state.
* @public
*/
get values(): TValue[];
/**
* Get `Observable` with all `keys` of your `Record` object state.
* @public
*/
readonly keys$: Observable<TKey[]>;
/**
* Get `Observable` with all `values` of your `Record` object state.
* @public
*/
readonly values$: Observable<TValue[]>;
/**
* Set item to object in state.
* @public
* @param {TKey} key - Key to set into.
* @param {TValue} value - Value to set within `key`.
*/
setItem(key: TKey, value: TValue): void;
/**
* Remove item from object in state.
* @public
* @param {TKey} key - Key to remove item within.
*/
removeItem(key: TKey): void;
/**
* Remove all items from object in state.
* @public
*/
removeAllItems(): void;
protected setNewValue(value: Record<TKey, TValue> | null): void;
protected catchError(error: Error | TypeError, actionName: string): void;
protected validateDataType(data: unknown): void;
}