How to use @storybook/channels - 5 common examples

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 gymnastjs / picturebook / config / config.js View on Github external
/* eslint-disable */

import { configure, setAddon } from '@storybook/react'
import { setOptions } from '@storybook/addon-options'
import JSXAddon from 'storybook-addon-jsx'
import params from '../params'

if (
  typeof window === 'object' &&
  window.navigator &&
  /node\.js/i.test(window.navigator.userAgent)
) {
  var addons = require('@storybook/addons').default
  var Channel = require('@storybook/channels').default
  addons.setChannel(
    new Channel({
      transport: {
        setHandler: function() {},
        send: function() {},
      },
    })
  )
}

setOptions({
  downPanelInRight: true,
  hierarchySeparator: /\./,
  name: params.projectName,
  url: params.projectUrl,
})

setAddon(JSXAddon)
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 });
}
github storybookjs / storybook / lib / channel-websocket / src / index.ts View on Github external
export default function createChannel({ url, async, onError }: CreateChannelArgs) {
  const transport = new WebsocketTransport({ url, onError });
  return new Channel({ transport, async });
}

@storybook/channels

MIT
Latest version published 1 day ago

Package Health Score

95 / 100
Full package analysis