ngrx-event-bus
Version:
Angular and RxJs event bus with Mediator Pattern
37 lines (36 loc) • 1.58 kB
TypeScript
import { Subscription } from 'rxjs';
import { IEvent } from '../interface/IEvent';
import { EmitEvent, EmitRecord } from '../interface/Event';
import * as i0 from "@angular/core";
export declare class NgRxEventBusService {
private eventRegister;
private eventLastEmitted;
constructor();
/**
* register event with or without default value.
* @param event should be IEvent type.
* @param defaultValue is option if data passed BehaviorSubject type has been considered else Subject type.
*/
registerEvent(event: IEvent, defaultValue?: unknown): void;
/**
* unregister the event.
* @param event should be IEvent type.
*/
unregisterEvent(event: IEvent, soft?: boolean): boolean;
/**
* Binding function to subscribe the published event.
* If event has not registered, it will register the same with default Subject type
* @param event should be IEvent type.
* @param action callback function when something event got publish.
* @param emittedValue by the event based on selected enum.
*/
on(event: IEvent, action: any, emittedValue?: EmitRecord): Subscription;
/**
* Publish event using this function.
* If event has not registered it will register it with default BehaviorSubject type
* @param event should be EmitEvent type.
*/
emit(event: EmitEvent): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgRxEventBusService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgRxEventBusService>;
}