Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@storybook/channels
Advanced tools
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.
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);
EventEmitter3 is a high-performance event emitter. While it provides similar event-driven communication capabilities, it does not include a transport layer for communication between different environments like @storybook/channels does.
Mitt is a tiny functional event emitter / pubsub. It offers similar event handling functionality but lacks the built-in transport layer for cross-environment communication that @storybook/channels provides.
FAQs
Unknown package
The npm package @storybook/channels receives a total of 7,530,136 weekly downloads. As such, @storybook/channels popularity was classified as popular.
We found that @storybook/channels demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.