UNPKG

@lithiumjs/angular

Version:

Reactive components made easy. Lithium provides utilities that enable seamless reactive state and event interactions for Angular components.

60 lines (59 loc) 3.36 kB
import { Subject } from "rxjs"; import type { ImmutableMap } from "../lang-utils"; export type EventType = string; export declare namespace EventMetadata { const SUBJECT_TABLE_MERGED_KEY = "$$EVENTSOURCE_SUBJECT_TABLE_MERGED"; const BOOTSTRAPPED_KEY = "$$EVENTSOURCE_BOOTSTRAPPED"; const LIFECYCLE_REGISTRATION_KEY = "$$EVENTSOURCE_LIFECYCLE_REGISTRATION"; interface ConfigOptions { eventType: EventType; skipMethodCheck?: boolean; unmanaged?: boolean; } interface SubjectInfo extends ConfigOptions { subject: Subject<any>; } type PropertySubjectMap = Map<string | symbol, SubjectInfo>; type EventSubjectTable = Map<EventType, PropertySubjectMap>; type InstanceBootstrapMap = Map<EventType, boolean>; type LifecycleRegistrationMap = Map<EventType, boolean>; type LifecycleCallbackMap = Map<EventType, Array<(...args: any[]) => void>>; /** @description Gets the metadata map object for the given target class (or its inheritted classes). */ function GetEventSubjectTable(target: Object): EventSubjectTable; /** @description Gets the metadata map object for the given target class. */ function GetOwnEventSubjectTable(target: Object): EventSubjectTable; function GetInstanceBootstrapMap(target: Object): InstanceBootstrapMap; function GetOwnLifecycleRegistrationMap(target: Object): LifecycleRegistrationMap; /** @description Gets own and inherited lifecycle registration data merged into a single Map. */ function GetLifecycleRegistrationMap(target: Object): ImmutableMap<LifecycleRegistrationMap>; function GetOwnLifecycleCallbackMap(target: Object): LifecycleCallbackMap; /** @description Gets own and inherited lifecycle callback data merged into a single Map. */ function GetLifecycleCallbackMap(target: Object): ImmutableMap<LifecycleCallbackMap>; /** * @description * Gets the property subject map for the given event type from the metadata map for the given target class (or its inheritted classes). */ function GetPropertySubjectMap(type: EventType, target: Object): PropertySubjectMap; /** * @description * Gets the property subject map for the given event type from the metadata map for the given target class. */ function GetOwnPropertySubjectMap(type: EventType, target: Object): PropertySubjectMap; function GetLifecycleCallbackList(target: Object, type: EventType): ReadonlyArray<(...args: any[]) => void>; function HasOwnEventSubjectTable(target: Object): boolean; function SetEventSubjectTable(target: Object, map: EventSubjectTable): void; function AddLifecycleCallback(target: Object, type: EventType, callback: (...args: any[]) => void): void; function RemoveLifecycleCallback(target: Object, type: EventType, callback: (...args: any[]) => void): void; /** * @description Copy all metadata from the source map to the target map. * * Note: This mutates the target map. **/ function CopySubjectTable(target: EventSubjectTable, source: EventSubjectTable, overwrite?: boolean): EventSubjectTable; /** * @description Merge own and inheritted metadata into a single map. * * Note: This mutates the object's metadata. **/ function CopyInherittedSubjectTable(object: any): EventSubjectTable; }