All files / src/services si-event-bus.ts

100% Statements 4/4
100% Branches 7/7
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                                  11x          
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Injectable } from '@angular/core';
import { SiEventBusBase, SiEventType } from '@siemens/dashboards-ng/event-bus';
 
/**
 * Injectable event bus service for cross-widget communication.
 *
 * By default, uses {@link SiEventType} which provides `filter`, `languageChange`, and `themeChange` events.
 * To use custom events, pass your own event type union as a generic argument:
 *
 * ```ts
 * type MyEvent =
 *   | { name: 'customAction'; data: string }
 *   | { name: 'statusUpdate'; data: boolean };
 *
 * const eventBus = inject(SiEventBus<MyEvent>);
 * eventBus.emit('customAction', 'payload');
 * ```
 */
@Injectable({
  providedIn: 'root'
})
export class SiEventBus<ET> extends SiEventBusBase<
  ET extends { name: string; data: unknown } ? ET : SiEventType
> {}
 
export type { SiEventType };