Merge pull request #16142 from RoadieHQ/typed-event-params

make `EventParams` typed for tidier event handling
This commit is contained in:
Fredrik Adelöw
2023-02-02 16:20:20 +01:00
committed by GitHub
3 changed files with 9 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-events-node': patch
---
Make `EventParams` typed for implementing tidier event handling.
+2 -2
View File
@@ -14,8 +14,8 @@ export interface EventBroker {
}
// @public (undocumented)
export interface EventParams {
eventPayload: unknown;
export interface EventParams<TPayload = unknown> {
eventPayload: TPayload;
metadata?: Record<string, string | string[] | undefined>;
topic: string;
}
+2 -2
View File
@@ -17,7 +17,7 @@
/**
* @public
*/
export interface EventParams {
export interface EventParams<TPayload = unknown> {
/**
* Topic for which this event should be published.
*/
@@ -25,7 +25,7 @@ export interface EventParams {
/**
* Event payload.
*/
eventPayload: unknown;
eventPayload: TPayload;
/**
* Metadata (e.g., HTTP headers and similar for events received from external).
*/