angular/devtools/projects/protocol/src/lib/message-bus.ts
hawkgs b5fc949840 fix(devtools): MessageBus.on return type (#62898)
It appears that the intent is to return an unlisten function when `on` is called. The message bus implementations indicate that. However, the `MessageBus` abstract class returns `void` instead.

Change to `on: () => void`.

PR Close #62898
2025-07-31 09:16:15 +00:00

16 lines
558 B
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export type Parameters<F> = F extends (...args: infer T) => any ? T : never;
export abstract class MessageBus<T> {
abstract on<E extends keyof T>(topic: E, cb: T[E]): () => void;
abstract once<E extends keyof T>(topic: E, cb: T[E]): void;
abstract emit<E extends keyof T>(topic: E, args?: Parameters<T[E]>): boolean;
abstract destroy(): void;
}