Skip to content

Commit

Permalink
Add JSDOc comment for ControllerMessenger class
Browse files Browse the repository at this point in the history
  • Loading branch information
Gudahtt committed Mar 11, 2021
1 parent cc8f81d commit 3ed24a6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ControllerMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export type ExtractEventPayload<Event, T> = Event extends { type: T; payload: in
type ActionConstraint = { type: string; handler: (...args: any) => unknown };
type EventConstraint = { type: string; payload: unknown[] };

/**
* A messaging system for controllers.
*
* The controller messenger allows registering functions as 'actions' that can be called elsewhere,
* and it allows publishing and subscribing to events. Both actions and events are identified by
* unique strings.
*/
export class ControllerMessenger<Action extends ActionConstraint, Event extends EventConstraint> {
private actions = new Map<Action['type'], unknown>();

Expand Down

0 comments on commit 3ed24a6

Please sign in to comment.