@muspellheim/shared
    Preparing search index...

    Class OutputTracker<T>

    Track output events.

    This is one of the nullability patterns from James Shore's article on testing without mocks.

    Example implementation of an event store:

    async record(event) {
    // ...
    this.dispatchEvent(new CustomEvent("eventRecorded", { detail: event }));
    }

    trackEventsRecorded() {
    return new OutputTracker(this, "eventRecorded");
    }

    Example usage:

    const eventsRecorded = eventStore.trackEventsRecorded();
    // ...
    const data = eventsRecorded.data(); // [event1, event2, ...]

    Type Parameters

    • T = unknown
    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Create a tracker for a specific event of an event target.

      Type Parameters

      • T = unknown

      Parameters

      • eventTarget: EventTarget

        The target to track.

      • event: string

        The event name to track.

      Returns OutputTracker<T>

    Accessors

    Methods

    • Create a tracker for a specific event of an event target.

      Type Parameters

      • T

      Parameters

      • eventTarget: EventTarget

        The target to track.

      • event: string

        The event name to track.

      Returns OutputTracker<T>