Evit packages documentation
    Preparing search index...

    Function defineEvent

    • Defines a new typed event with a payload and tag.

      Type Parameters

      • const Tag

        A unique identifier for the event.

      • P = void

        The payload type.

      Parameters

      • tag: Tag

        The tag for the event.

      • Optional_infer: P

        Optionally used to infer payload type (can use withPayload<T>()).

      Returns Action<P, Tag>

      The event that you can subscribe to and listen.

      const event = defineEvent('user.created')

      // or with a payload
      const eventWithPayload = defineEvent('user.created', withPayload<{ id: number }>())