@storybook/channels

  • Version 7.6.17
  • Published
  • 42.1 kB
  • 6 dependencies
  • MIT license

Install

npm i @storybook/channels
yarn add @storybook/channels
pnpm add @storybook/channels

Overview

Overview not available.

Index

Functions

function createBrowserChannel

createBrowserChannel: ({ page, extraTransports }: Options) => Channel;
  • Creates a new browser channel instance.

    Parameter options

    The options object.

    Parameter

    {Page} options.page - The puppeteer page instance.

    Parameter

    {ChannelTransport[]} [options.extraTransports=[]] - An optional array of extra channel transports.

    Returns

    {Channel} - The new channel instance.

function createPostMessageChannel

createPostMessageChannel: ({ page }: Config) => Channel;
  • Parameter config

    The configuration object.

    Returns

    {Channel} The channel instance.

    Deprecated

    This function is deprecated. Use the createBrowserChannel factory function from @storybook/channels instead. This API will be removed in 8.0.

function createWebSocketChannel

createWebSocketChannel: ({ url, async, onError }: CreateChannelArgs) => Channel;
  • Parameter options

    The options for creating the channel.

    Parameter

    {string} [options.url] - The URL of the WebSocket server to connect to.

    Parameter

    {boolean} [options.async=false] - Whether the channel should be asynchronous.

    Parameter

    {OnError} [options.onError] - A function to handle errors that occur during the channel's lifetime.

    Returns

    {Channel} - The newly created channel.

    Deprecated

    This function is deprecated. Use the createBrowserChannel factory function from @storybook/channels instead. This API will be removed in 8.0.

Classes

class Channel

class Channel {}

    constructor

    constructor(input: ChannelArgsMulti);

      constructor

      constructor(input: ChannelArgsSingle);

        property hasTransport

        readonly hasTransport: boolean;

          property isAsync

          readonly isAsync: boolean;

            method addListener

            addListener: (eventName: string, listener: Listener) => void;

              method emit

              emit: (eventName: string, ...args: any) => void;

                method eventNames

                eventNames: () => string[];

                  method last

                  last: (eventName: string) => any;

                    method listenerCount

                    listenerCount: (eventName: string) => number;

                      method listeners

                      listeners: (eventName: string) => Listener[] | undefined;

                        method off

                        off: (eventName: string, listener: Listener) => void;

                          method on

                          on: (eventName: string, listener: Listener) => void;

                            method once

                            once: (eventName: string, listener: Listener) => void;

                              method removeAllListeners

                              removeAllListeners: (eventName?: string) => void;

                                method removeListener

                                removeListener: (eventName: string, listener: Listener) => void;

                                  class PostMessageTransport

                                  class PostMessageTransport implements ChannelTransport {}

                                    constructor

                                    constructor(config: Config);

                                      method send

                                      send: (event: ChannelEvent, options?: any) => Promise<any>;
                                      • Sends event to the associated window. If the window does not yet exist the event will be stored in a buffer and sent when the window exists.

                                        Parameter event

                                      method setHandler

                                      setHandler: (handler: ChannelHandler) => void;

                                        class WebsocketTransport

                                        class WebsocketTransport implements ChannelTransport {}

                                          constructor

                                          constructor({ url, onError }: WebsocketTransportArgs);

                                            method send

                                            send: (event: any) => void;

                                              method setHandler

                                              setHandler: (handler: ChannelHandler) => void;

                                                Interfaces

                                                interface ChannelEvent

                                                interface ChannelEvent {}

                                                  property args

                                                  args: any[];

                                                    property from

                                                    from: string;

                                                      property type

                                                      type: string;

                                                        interface ChannelTransport

                                                        interface ChannelTransport {}

                                                          method send

                                                          send: (event: ChannelEvent, options?: any) => void;

                                                            method setHandler

                                                            setHandler: (handler: ChannelHandler) => void;

                                                              interface Listener

                                                              interface Listener {}

                                                                call signature

                                                                (...args: any[]): void;

                                                                  Type Aliases

                                                                  type ChannelHandler

                                                                  type ChannelHandler = (event: ChannelEvent) => void;

                                                                    Package Files (4)

                                                                    Dependencies (6)

                                                                    Dev Dependencies (1)

                                                                    Peer Dependencies (0)

                                                                    No peer dependencies.

                                                                    Badge

                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@storybook/channels.

                                                                    • Markdown
                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@storybook/channels)
                                                                    • HTML
                                                                      <a href="https://www.jsdocs.io/package/@storybook/channels"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>