UNPKG

@studiohyperdrive/ngx-utils

Version:

A series of abstracts, utils, pipes and services for Angular applications.

63 lines (62 loc) 2.66 kB
import { Observable } from 'rxjs'; import { NgxWindowService } from '@studiohyperdrive/ngx-core'; import * as i0 from "@angular/core"; /** * A service that wraps the BroadCastChannel API and provides an Observable based implementation to the channel messages. * * For more information: * https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel */ export declare class NgxBroadcastChannelService { private readonly windowService; /** * A record holding all the broadcast channels */ private broadcastChannel; constructor(windowService: NgxWindowService); /** * initChannel * * The initChannel method initializes a new BroadcastChannel instance. * * @param args{ConstructorParameters<typeof BroadcastChannel>} - The arguments to pass to the BroadcastChannel constructor. */ initChannel(...args: ConstructorParameters<typeof BroadcastChannel>): void; /** * closeChannel * * The closeChannel method closes a selected BroadcastChannel instance. * * @param channelName{string} - The name of the Broadcast Channel. */ closeChannel(channelName: string): void; /** * postMessage * * The postMessage method sends a message to a selected BroadcastChannel instance. * * @param channelName{string} - The name of the Broadcast Channel. * @param message{any} - The payload to send through the channel. */ postMessage<MessageType = any>(channelName: string, message: MessageType): void; /** * selectChannelMessages * * The selectChannelMessages method subscribes to the `message` (bc.onmessage) event of a selected BroadcastChannel instance. * * @param channelName{string} - The name of the Broadcast Channel. * @returns Observable<MessageEvent> - The message event of the channel wrapped in an observable. */ selectChannelMessages<MessageType = any>(channelName: string): Observable<MessageEvent<MessageType>>; /** * selectChannelMessageErrors * * The selectChannelMessageErrors method subscribes to the `messageerror` (bc.onmessageerror) event of a selected BroadcastChannel instance. * * @param channelName{string} - The name of the Broadcast Channel. * @returns Observable<MessageEvent> - The messageerror event of the channel wrapped in an observable. */ selectChannelMessageErrors<MessageType = any>(channelName: string): Observable<MessageEvent<MessageType>>; static ɵfac: i0.ɵɵFactoryDeclaration<NgxBroadcastChannelService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NgxBroadcastChannelService>; }