libs/core/building-blocks/src/lib/building-block/building-block-interface.ts
That's the core contract a Building Block needs to fulfill. Any actual implementation needs to inherit from the Abstract component in order to be technically discoverable by a Building Block collecting page.
BuildingBlockBase,Stateable<T>,Resourceable<U>,BusinessEventAble,Editable
Properties |
Methods |
| navigate | |||||||||
navigate(type: BUILDING_BLOCK_NAVIGATION_TYPE, payload?: string)
|
|||||||||
|
Inherited from
BuildingBlockBase
|
|||||||||
|
Parameters :
Returns :
void
|
| onPageConnection |
onPageConnection()
|
|
Inherited from
BuildingBlockBase
|
|
Returns :
void
|
| onPageDisconnected |
onPageDisconnected()
|
|
Inherited from
BuildingBlockBase
|
|
Returns :
void
|
| setValidationConfiguration | ||||||
setValidationConfiguration(data: ValidationConfigItem[])
|
||||||
|
Inherited from
BuildingBlockBase
|
||||||
|
Parameters :
Returns :
void
|
| acl | |
| Type |
AclEvaluationInterface
|
| aclTag | |
| Type |
AclTag | null
|
| completion$ | |
| Type |
BehaviorSubject<boolean>
|
| connected$ | |
| Type |
Subject<void>
|
| disconnected$ | |
| Type |
Subject<void>
|
| id | |
| Type |
string
|
| loadingStatus$ | |
| Type |
Observable<Record<string, boolean>>
|
| navigateEvent$ | |
| Type |
EventEmitter<BuildingBlockNavigationEvent>
|
| renderReady$ | |
| Type |
BehaviorSubject<boolean>
|
| trackForm$ | |
| Type |
EventEmitter<UntypedFormGroup>
|
import { AclEvaluationInterface, AclTag } from '@allianz/taly-acl';
import { Deferred, ValidationConfigItem } from '@allianz/taly-core';
import { EventEmitter } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { BUILDING_BLOCK_NAVIGATION_TYPE, BuildingBlockNavigationEvent } from './navigation';
/**
* The bare minimum for a Building Block
*/
interface BuildingBlockBase {
id: string;
completion$: BehaviorSubject<boolean>;
renderReady$: BehaviorSubject<boolean>;
disconnected$: Subject<void>;
connected$: Subject<void>;
acl: AclEvaluationInterface;
aclTag: AclTag | null;
readonly loadingStatus$: Observable<Record<string, boolean>>;
navigateEvent$: EventEmitter<BuildingBlockNavigationEvent>;
navigate(type: BUILDING_BLOCK_NAVIGATION_TYPE, payload?: string): void;
// lifecycle
onPageConnection(): void;
onPageDisconnected(): void;
setValidationConfiguration(data: ValidationConfigItem[]): void;
trackForm$: EventEmitter<UntypedFormGroup>;
}
/**
* How to provide data we need to work properly
* This cna be lists for Dropdowns, data to display only, image urls etc
*/
interface Resourceable<U> {
resources: U;
// 01. provide data to work
setResources(data: U): void;
rawResources: U;
setRawResources(data: U): void;
}
/**
* Manage Building Block State
*/
interface Stateable<T> {
state: T;
stateChange$: Subject<T>;
// to be called whenever the state has changed
// so the facade knows about it and can store the current data
stateChanged(): void;
// 03. Restore or read the actual contracted data for this Building Block
setState(state: T): void;
getState(): T;
}
interface Editable {
getForm(): UntypedFormGroup | undefined;
}
export interface BusinessEvent {
event: string;
deferred: Deferred;
}
interface BusinessEventAble {
businesssEventCall$: EventEmitter<BusinessEvent>;
}
/**
* That's the core contract a Building Block needs to fulfill.
* Any actual implementation needs to inherit from the Abstract component
* in order to be technically discoverable by a Building Block collecting page.
*/
export interface BuildingBlockInterface<
T = Record<string, unknown>,
U = Record<string, unknown> | undefined
> extends BuildingBlockBase,
Stateable<T>,
Resourceable<U>,
BusinessEventAble,
Editable {}