Socket
Socket
Sign inDemoInstall

@storybook/channels

Package Overview
Dependencies
Maintainers
5
Versions
1852
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/channels

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.


Version published
Weekly downloads
12M
decreased by-3.03%
Maintainers
5
Install size
7.17 kB
Created
Weekly downloads
 

Package description

What is @storybook/channels?

The @storybook/channels package is used within the Storybook ecosystem to facilitate communication between different parts of the Storybook environment, such as between the Storybook UI and the preview iframe where stories are rendered. It provides an event-driven channel that can be used for bidirectional communication.

What are @storybook/channels's main functionalities?

Creating a channel

This code sample demonstrates how to create a new channel using the @storybook/channels package. The 'transport' object would be an implementation of the transport layer that the channel will use to send and receive messages.

import Channel from '@storybook/channels';
const channel = new Channel({ transport });

Sending a message

This code sample shows how to send a message with an event name and associated data through the channel. Other parts of the application can listen for 'eventName' and react accordingly.

channel.emit('eventName', eventData);

Listening for a message

This code sample illustrates how to listen for messages on the channel. The 'eventHandler' function will be called with the event data whenever a message with 'eventName' is emitted.

channel.on('eventName', eventHandler);

Removing a listener

This code sample shows how to remove a previously added event listener from the channel. This is useful for cleanup and preventing memory leaks.

channel.removeListener('eventName', eventHandler);

Other packages similar to @storybook/channels

Changelog

Source

7.0.0-alpha.57 (December 3, 2022)

Bug Fixes
  • Vite: Reinstate (deprecated) StorybookViteConfig #20057
  • Docs: using targeted styles, not components to style MDX #19958
  • Docs: Return to filtering toolbars in docs mode, but don't filter menu #19959
  • Angular: Don't set argType.defaultValue in angular/compodoc #19935
  • NextJS: Support next/image component in v12/13 properly #20028
  • Svelte: Use JSDocs in JS CLI templates and put manual enum arg type back as it is not inferred #20042
Maintenance
  • CLI: Add a new version-update check telemetry event #20074
  • CLI: Add upgrade telemetry details #20064
  • Core: added .entries property to error thrown when duplicate stories are present #20038
Build
  • Improve framework version specific story handling #20027
  • Fix repro templates script #20063
  • Build: replace image placeholder url in example stories for nextjs #20069
  • Build: improve inDevelopment mode for yarn task #20067
  • Build: revamp interactions e2e test #20060
Dependency Upgrades
  • Build: Update jest pretty-format to 29 #20047

Readme

Source

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) {}
}

For more information visit: storybook.js.org

Keywords

FAQs

Package last updated on 03 Dec 2022

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc