@versatiledatakit/shared
Version:
Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.
114 lines (113 loc) • 3.84 kB
TypeScript
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { RouterService, RouteState } from '../../router';
import { StoreState } from '../../ngrx';
import { ComponentModel, ComponentState, StatusType } from '../model';
import * as i0 from "@angular/core";
/**
* ** Service that manage Components State.
*/
export declare abstract class ComponentService {
/**
* ** Initialize Component State and return Model.
*/
abstract init(id: string, routeState: RouteState): Observable<ComponentModel>;
/**
* ** Set Component status to IDLE.
*/
abstract idle(componentState: ComponentState): void;
/**
* ** Load Component State and return Model.
*/
abstract load(componentState: ComponentState): Observable<ComponentModel>;
/**
* ** Update Component State.
*/
abstract update(componentState: ComponentState): void;
/**
* ** Acknowledge if has ComponentState in segment.
*
* - true - has ComponentState.
* - false - doesn't have ComponentState.
*/
abstract hasInSegment(id: string, routePathSegments: string[]): Observable<boolean>;
/**
* ** Listener that fires once after successful Component State initialization and returns Model.
*/
abstract onInit(id: string, routePathSegments: string[]): Observable<ComponentModel>;
/**
* ** Listener that fires once after successful Component State load and returns Model.
*/
abstract onLoaded(id: string, routePathSegments: string[]): Observable<ComponentModel>;
/**
* ** Returns stream with value Component Model and fires whenever Component State changes in Store.
*
* - If no statusWatch provided by default will listen for statuses {@link LOADED} and {@link FAILED}.
*/
abstract getModel(id: string, routePathSegments: string[], statusWatch?: Array<StatusType | '*'>): Observable<ComponentModel>;
/**
* ** Dispatch GenericAction with provided Type, ComponentState and optionally task.
*/
abstract dispatchAction(type: string, componentState: ComponentState, task?: string): void;
/**
* ** Initialize Service.
*/
abstract initialize(): void;
}
/**
* @inheritDoc
*/
export declare class ComponentServiceImpl extends ComponentService {
private readonly store$;
private readonly routerService;
private readonly componentsStateHelper;
/**
* ** Constructor.
*/
constructor(store$: Store<StoreState>, routerService: RouterService);
/**
* @inheritDoc
*/
init(id: string, routeState: RouteState): Observable<ComponentModel>;
/**
* @inheritDoc
*/
idle(componentState: ComponentState): void;
/**
* @inheritDoc
*/
load(componentState: ComponentState): Observable<ComponentModel>;
/**
* @inheritDoc
*/
update(componentState: ComponentState): void;
/**
* @inheritDoc
*/
hasInSegment(id: string, routePathSegments: string[]): Observable<boolean>;
/**
* @inheritDoc
*/
onInit(id: string, routePathSegments: string[]): Observable<ComponentModel>;
/**
* @inheritDoc
*/
onLoaded(id: string, routePathSegments: string[]): Observable<ComponentModel>;
/**
* @inheritDoc
*/
getModel(id: string, routePathSegments: string[], statusWatch?: Array<StatusType | '*'>): Observable<ComponentModel>;
/**
* @inheritDoc
*/
dispatchAction(type: string, componentState: ComponentState, task?: string): void;
/**
* @inheritDoc
*/
initialize(): void;
private _getComponentState;
private _isComponentInStatus;
private _createModel;
static ɵfac: i0.ɵɵFactoryDeclaration<ComponentServiceImpl, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ComponentServiceImpl>;
}