UNPKG

@versatiledatakit/shared

Version:

Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.

128 lines (127 loc) 2.77 kB
import { ApiPredicate, ErrorRecord } from '../../../common'; import { RouterState } from '../../router'; import { ComponentState, StatusType } from './state'; import { AbstractComponentModel } from './component.model.interface'; /** * ** Generic Model for all Components. */ export declare class ComponentModel extends AbstractComponentModel { protected _componentState: ComponentState; protected _routerState: RouterState; /** * ** Constructor. */ constructor(_componentState: ComponentState, _routerState: RouterState); /** * ** Factory method. */ static of(componentState: ComponentState, routerState: RouterState): ComponentModel; /** * @inheritDoc */ get routerState(): RouterState; /** * @inheritDoc */ get status(): StatusType; /** * @inheritDoc */ get routePath(): string; /** * ** Reference to previous model for comparison only. */ readonly previousModel: Readonly<ComponentModel>; /** * @inheritDoc */ getComponentState(): ComponentState; /** * @inheritDoc */ withSearch(search: string): this; /** * @inheritDoc */ withPage(page: number, size: number): this; /** * @inheritDoc */ withFilter(filterPredicates: ApiPredicate[]): this; /** * @inheritDoc */ withRequestParam(key: string, value: any): this; /** * @inheritDoc */ withData(key: string, data: any): this; /** * @inheritDoc */ withTask(taskIdentifier: string): this; /** * @inheritDoc */ clearTask(): this; /** * @inheritDoc */ getTask(): string; /** * @inheritDoc */ getTaskUniqueIdentifier(): string; /** * @inheritDoc */ withError(errorRecord: ErrorRecord): this; /** * @inheritDoc */ clearErrors(): this; /** * @inheritDoc */ removeErrorCode(...errorCodes: string[]): this; /** * @inheritDoc */ removeErrorCodePatterns(...errorCodePatterns: string[]): this; /** * @inheritDoc */ withUiState(key: string, value: any): this; /** * @inheritDoc */ getUiState<T>(key: string): T; /** * @inheritDoc */ withStatusIdle(): this; /** * @inheritDoc */ withStatusLoading(): this; /** * @inheritDoc */ withStatusLoaded(): this; /** * @inheritDoc */ withStatusFailed(): this; /** * @inheritDoc */ updateComponentState(patchState: Partial<ComponentState>): this; /** * @inheritDoc */ prepareForDestroy(): this; /** * @inheritDoc */ isModified(model: ComponentModel): boolean; }