Socket
Socket
Sign inDemoInstall

@storybook/channel-websocket

Package Overview
Dependencies
Maintainers
8
Versions
1496
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/channel-websocket


Version published
Weekly downloads
1.5M
increased by0.96%
Maintainers
8
Weekly downloads
 
Created

What is @storybook/channel-websocket?

The @storybook/channel-websocket npm package is used within the Storybook ecosystem to facilitate communication between the Storybook UI and the server or between different frames of the UI using WebSockets. This package is particularly useful for enabling real-time updates and interactions in the Storybook UI, which is a tool for developing UI components in isolation for React, Vue, Angular, and more.

What are @storybook/channel-websocket's main functionalities?

Establishing WebSocket connection

This code sample demonstrates how to establish a WebSocket connection using the WebSocketTransport class provided by @storybook/channel-websocket. This is essential for enabling real-time communication between the Storybook UI and the server.

import { WebSocketTransport } from '@storybook/channel-websocket';

const transport = new WebSocketTransport({ url: 'ws://localhost:9001' });
const channel = createChannel({ transport });

Sending messages

This code sample shows how to send messages over the established WebSocket connection. This is useful for triggering events or sending data from one part of the UI to another or to the server.

channel.emit('event-name', { payload: 'data' });

Receiving messages

This code sample illustrates how to listen for messages on the WebSocket channel. This allows the UI to react to data or events sent from the server or other parts of the UI.

channel.on('event-name', (data) => {
  console.log('Received data:', data);
});

Other packages similar to @storybook/channel-websocket

Keywords

FAQs

Package last updated on 31 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc