export interface Constructor { new(...args: any[]): T; prototype: T; } export type PromiseOrValue = T | PromiseLike; export type Factory = (...args: any[]) => T; export type Predicate = (x: T) => boolean; export type MatchingMemberKeys = { [K in keyof From]: From[K] extends T ? K : never}[keyof From]; export type NotMatchingMemberKeys = { [K in keyof From]: From[K] extends T ? never : K}[keyof From]; export type ExtractMembers = Pick>; export type ExcludeMembers = Pick>; export interface MapOf { [key: string]: T; } export interface IDestroyable { destroy(): void; } export interface IRemovable { remove(): void; } export interface ICancellation { throwIfRequested(): void; isRequested(): boolean; isSupported(): boolean; register(cb: (e: any) => void): IDestroyable; } /** * Интерфейс поддерживающий асинхронную активацию */ export interface IActivatable { /** * @returns Boolean indicates the current state */ isActive(): boolean; /** * Starts the component activation * @param ct cancellation token for this operation */ activate(ct?: ICancellation): Promise; /** * Starts the component deactivation * @param ct cancellation token for this operation */ deactivate(ct?: ICancellation): Promise; /** * Sets the activation controller for this component * @param controller The activation controller * * Activation controller checks whether this component * can be activated and manages the active state of the * component */ setActivationController(controller: IActivationController): void; /** Indicates whether this component has an activation controller */ hasActivationController(): boolean; /** * Gets the current activation controller for this component */ getActivationController(): IActivationController; } export interface IActivationController { activating(component: IActivatable, ct?: ICancellation): Promise; activated(component: IActivatable, ct?: ICancellation): Promise; deactivating(component: IActivatable, ct?: ICancellation): Promise; deactivated(component: IActivatable, ct?: ICancellation): Promise; deactivate(ct?: ICancellation): Promise; activate(component: IActivatable, ct?: ICancellation): Promise; hasActive(): boolean; getActive(): IActivatable; } export interface IAsyncComponent { getCompletion(): Promise; } export interface ICancellable { cancel(reason?: any): void; } export interface IObservable { on(next: (x: T) => void, error?: (e: any) => void, complete?: () => void): IDestroyable; next(ct?: ICancellation): Promise; } export interface IObserver { next(event: T): void; error(e: any): void; complete(): void; } export interface TextWriter { write(obj: any): void; write(format: string, ...args: any[]): void; writeLine(obj?: any): void; writeLine(format: string, ...args: any[]): void; writeValue(value: any, spec?: string): void; }