How to use the @storybook/channels function in @storybook/channels

To help you get started, we’ve selected a few @storybook/channels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storybookjs / storybook / app / react-native / src / preview / index.tsx View on Github external
this._asyncStorage = params.asyncStorage;
    }

    const onDeviceUI = params.onDeviceUI !== false;
    const { initialSelection, shouldPersistSelection } = params;

    try {
      channel = addons.getChannel();
    } catch (e) {
      // getChannel throws if the channel is not defined,
      // which is fine in this case (we will define it below)
    }

    if (!channel || params.resetStorybook) {
      if (onDeviceUI && params.disableWebsockets) {
        channel = new Channel({ async: true });
        this._setInitialStory(initialSelection, shouldPersistSelection);
      } else {
        const host = getHost(params.host || 'localhost');
        const port = `:${params.port || 7007}`;

        const query = params.query || '';
        const { secured } = params;
        const websocketType = secured ? 'wss' : 'ws';
        const httpType = secured ? 'https' : 'http';

        const url = `${websocketType}://${host}${port}/${query}`;
        webUrl = `${httpType}://${host}${port}`;
        channel = createChannel({
          url,
          async: onDeviceUI,
          onError: () => {
github storybookjs / storybook / lib / channel-postmessage / src / index.ts View on Github external
export default function createChannel({ page }: Config): Channel {
  const transport = new PostmsgTransport({ page });
  return new Channel({ transport });
}
github storybookjs / storybook / lib / addons / src / storybook-channel-mock.ts View on Github external
export function mockChannel() {
  const transport = {
    setHandler: () => {},
    send: () => {},
  };

  return new Channel({ transport });
}

@storybook/channels

MIT
Latest version published 3 days ago

Package Health Score

95 / 100
Full package analysis