@intisy/bayonet
    Preparing search index...

    Interface Events

    How a plugin says something happened, and hears that something did.

    A topic is paired with its payload in the type system, so a publisher and a subscriber cannot disagree about the shape without the compiler saying so.

    interface Events {
        publish<T>(topic: TopicType<T>, payload: T): void;
        subscribe<T>(topic: TopicType<T>, listener: (value: T) => void): () => void;
    }
    Index
    • Says a topic carried this payload, to whoever is listening and to nobody in particular.

      Type Parameters

      • T

        the topic's payload type

      Parameters

      • topic: TopicType<T>

        the topic to publish on

      • payload: T

        the event payload

      Returns void

    • Hears this topic until the returned function is called.

      Type Parameters

      • T

        the topic's payload type

      Parameters

      • topic: TopicType<T>

        the topic to listen on

      • listener: (value: T) => void

        called with each payload published on topic

      Returns () => void

      a function that stops the subscription when called