Skip to content

Commit

Permalink
Add additional documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gudahtt committed Apr 22, 2021
1 parent 6ee460f commit 089ae86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/BaseControllerV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export class BaseController<
string | never
>;

/**
* The name of the controller.
*
* This is used by the ComposableController to construct a composed application state.
*/
public readonly name: N;

public readonly metadata: StateMetadata<S>;
Expand Down
6 changes: 6 additions & 0 deletions src/ComposableController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {

/**
* List of child controller instances
*
* This type encompasses controllers based up either BaseController or
* BaseControllerV2. The BaseControllerV2 type can't be included directly
* because the generic parameters it expects require knowing the exact state
* shape, so instead we look for an object with the BaseControllerV2 properties
* that we use in the ComposableController (name and state).
*/
export type ControllerList = (
| BaseController<any, any>
Expand Down
7 changes: 7 additions & 0 deletions src/ControllerMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ type ExtractEventPayload<Event, T> = Event extends { type: T; payload: infer P }
: never;

type ActionConstraint = { type: string; handler: (...args: any) => unknown };

/**
* A valid ControllerMessenger Event.
*
* This type is used to constrain generic Event parameters, to ensure valid
* Event types are given.
*/
export type EventConstraint = { type: string; payload: unknown[] };

/**
Expand Down

0 comments on commit 089ae86

Please sign in to comment.