Neverending Prototype Mode

    @storybook/channels
    TypeScript icon, indicating that this package has built-in type declarations

    6.5.9 • Public • Published

    Storybook Channel

    Storybook Channel is similar to an EventEmitter. Channels are used with Storybook implementations to send/receive events between the Storybook Manager and the Storybook Renderer.

    class Channel {
      addListener(type, listener) {}
      addPeerListener(type, listener) {} // ignore events from itself
      emit(type, ...args) {}
      eventNames() {}
      listenerCount(type) {}
      listeners(type) {}
      on(type, listener) {}
      once(type, listener) {}
      prependListener(type, listener) {}
      prependOnceListener(type, listener) {}
      removeAllListeners(type) {}
      removeListener(type, listener) {}
    }

    The channel takes a Transport object as a parameter which will be used to send/receive messages. The transport object should implement this interface.

    class Transport {
      send(event) {}
      setHandler(handler) {}
    }

    Currently, channels are baked into storybook implementations and therefore this module is not designed to be used directly by addon developers. When developing addons, use the getChannel method exported by @storybook/addons module. For this to work, Storybook implementations should use the setChannel method before loading addons.

    import { addons } from '@storybook/addons';
    
    const channel = addons.getChannel();

    For more information visit: storybook.js.org

    Keywords

    Install

    npm i @storybook/channels

    DownloadsWeekly Downloads

    5,947,950

    Version

    6.5.9

    License

    MIT

    Unpacked Size

    21.4 kB

    Total Files

    8

    Last publish

    Collaborators

    • shilman
    • ndelangen
    • hypnosphi
    • tmeasday
    • igor-dv