import { HasNameAndHost } from '../base'; import { OtherBlocSearchCriteria } from './blocs-provider'; /** * Pure functions: * 1. One which will not modify the state themselves. * 2. No calculation at all in Pure functions. There only objective must be to set values, which can triggers sate change of your elements. */ export interface PureFunction { (newState: S): void; _ln_name: string; } export declare function deepFreeze(obj: any): any; /** * Bloc : Business Logic component, is a place where in you place all your business logic. * Its holds a state and all business logic which tries to modify this state should be inside this. * This exposes a single method emit to external Api, which must be used to emit new states. */ export declare abstract class Bloc extends HasNameAndHost { protected initState: S; protected listenToBlocs: string[]; private _listener_id_ref; private _listeners; private _state; protected _blocsMap: Record>; get blocsMap(): Record>; static search>(nameOfBlocToSearch: string, startingElement: HTMLElement, otherSearchCriteria?: OtherBlocSearchCriteria): B | undefined; /** * key is bloc name */ protected foundListenedBlocs: Record; subscriber_id: string; }>; /** * Called right after an HTMLElement is connected * @param ctx */ onConnection(ctx: HTMLElement): void; /** * Called before disconnection of HTMLElement */ onDisconnection(): void; /** * Override * @param blocName * @param newState */ protected reactToStateChangeFrom(blocName: string, newState: any): void; getBloc>(bloc_name: string): B; /** * * @param initState this is mostly used for rendering loading place holder [grey boxes]. * @param listenToBlocs onConnection of this bloc's host element, this bloc will start subscribe to state change from this blocs (present in the parent chain). * If a bloc is not found it will throw error */ constructor(initState: S, listenToBlocs?: string[]); get state(): S; /** * * @param newState Emits new state */ emit(newState: S): void; /** * * @param aPureFunction Used to subscribe to state changes */ _subscribe(aPureFunction: PureFunction): string; /** * * @param listeningId Unsubscribe to state listening state changes */ _unsubscribe(listeningId: string): void; }