import { Observable, Subject } from 'rxjs'; import { Destroyable, UnwrapObservable } from '../types'; export interface OmpBroadcastErrorMessage { name: string; message: string; } export interface OmpBroadcastMessageResponse { messageType: 'messageResponse'; requestMessageId: string; data?: DataType; error?: OmpBroadcastErrorMessage; } export interface OmpBroadcastMessage { messageType: 'message'; messageId: string; actionName: string; data?: DataType; } export interface OmpBroadcastSendOptions { timeout: number; } export declare class OmpBroadcastChannel implements Destroyable { private readonly _channelId; private readonly _onMessage$; private readonly _onResponse$; private _broadcastChannel; private _messageListener; private _messageerrorListener; protected _destroyed$: Subject; constructor(channelId: string); private init; protected _sendAndObserveResponse(message: OmpBroadcastMessage, sendOptions?: Partial): Observable>; protected sendResponse(responseToMessageId: string, responseValue: Observable | any): void; protected createMessageStream(actionName: string): Observable>; protected createDataStream(actionName: string): Observable; protected sendMessage(message: OmpBroadcastMessage): void; protected createMessage(actionName: string, data?: DataType): OmpBroadcastMessage; private _sendResponse; private _sendErrorResponse; get channelId(): string; destroy(): void; } export type OmpBroadcastChannelActionsMap> = { [K in Extract]: { requestType: T[K]['requestType'] extends undefined ? [void] : T[K]['requestType']; responseType: T[K]['responseType'] extends undefined ? void : T[K]['responseType']; }; }; export type OmpBroadcastChannelActionName> = Extract; /** * If remote method response is awaited value is always Observable. For methods that already return Observable we need to unwrap it as return type is already Observable */ export declare class TypedOmpBroadcastChannel> extends OmpBroadcastChannel { constructor(channelId: string); createRequestStream, ResponseType extends T[ActionName]['responseType']>(action: ActionName): Observable>; createRequestResponseStream, RequestType extends T[ActionName]['requestType'], ResponseType extends T[ActionName]['responseType']>(action: ActionName): Observable<[UnwrapObservable, (response: ResponseType) => void]>; sendAndObserveResponse, RequestType extends T[ActionName]['requestType'], ResponseType extends T[ActionName]['responseType']>(action: ActionName, arg?: RequestType, sendOptions?: Partial): Observable>; send, RequestType extends T[ActionName]['requestType']>(action: ActionName, arg?: RequestType): void; }