Skip to content

feat(dashboards-ng): event bus for widget communication#1647

Open
chintankavathia wants to merge 11 commits intomainfrom
feat/dashboard/event-bus
Open

feat(dashboards-ng): event bus for widget communication#1647
chintankavathia wants to merge 11 commits intomainfrom
feat/dashboard/event-bus

Conversation

@chintankavathia
Copy link
Member

@chintankavathia chintankavathia commented Mar 16, 2026

Introduces EventBus service to emit and subscribe events with data between widgets.
Also introduces getEventBusInstance util with separate entry point @siemens/dashboards-ng/event-bus to allow non angular widgets to utilize same service.

Usage

// to subscribe to an event
eventBus = inject(EventBus);

eventBus.on('languageChange').subscribe(lang => console.log(lang));

// to emit an event
eventBus.emit('languageChange', 'de');

// to access current snapshot of events

eventBus.snapshot(); // returns whole snapshots of all events

eventBus.snapshot('languageChange');  // returns only `languageChange` specific event snapshot

eventBus.snapshot('filter', ['location']); // returns `filter` event snapshots having filter keys matching `location`


// EventBus with custom event types

type MyCustomEventType = {name: 'foo'; data: boolean} 

eventBus = inject(EventBus<MyCustomEventType>);

eventBus.on('foo');
eventBus.emit('foo', false);


// Using EventBus instance in non angular widgets (e.g react/vue)

import {getEventBusInstance} from '@siemens/dashboards-ng/event-bus';

eventBus = getEventBusInstance();

Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a well-designed SiEventBus service for inter-widget communication, which is a significant and valuable feature. The implementation thoughtfully supports both Angular and non-Angular contexts by leveraging shared state on the window object, making it suitable for microfrontend architectures. The documentation and tests are comprehensive. My review includes suggestions to improve type safety by adhering to the project's style guide.

@chintankavathia chintankavathia force-pushed the feat/dashboard/event-bus branch from e0ac73d to ca9ea13 Compare March 16, 2026 05:54
@chintankavathia chintankavathia marked this pull request as ready for review March 16, 2026 06:19
@chintankavathia chintankavathia requested review from a team as code owners March 16, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant