npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

get-set-event

v3.0.3

Published

create, dispatch, and listen to custom events in react.

Readme

Events and Channels for react

This library offers functions and hooks to transfer data or functions across components or stores.

use 'createEvent()' to create an event. use 'createChannel()' to create a channel.

use event.trigger() to send data to subscribers. use channel.publish() to send message over a channel.

Channels or events are amazing way to send and recieve messages between components. These messages can have data or functions. there can be multiple subscribers to a channel or event.

Event and Channel are both similar in everyway. Channel has publish function to send messages. Events have trigger function to send data to subscribers.

you can also use another library called x-channel if you just want to create and manage channels of communication across components.

check Example on Stackblitz

Stackblitz Example

Events

  • creteEvent(): Creates and returns a new event.
  • useOnEvent(events, onEventCallback): Subscribes to an event and calls a callback when the event is triggered.
  • useOnEventOnce(events, onEventCallback): Subscribes to an event and calls a callback once when the event is triggered.
  • useEventData(event): Returns the last data of the event.
  • event.trigger(data, meta): Triggers the event with the given data and meta.
  • event.getState(): Returns the last state of the event.
  • event.getSubscriptionsCount(): Returns the number of active subscriptions to the event.
  • event.triggerAndDisable(data, meta): Triggers the event with the given data and meta and disables the event.
  • event.subscribeOnce(callback): Subscribes to the event and calls the callback once.
  const event = createEvent();
  const unsubscribe = event.subscribe((data, meta) => {
    console.log(data, meta);
  });
  event.trigger({ message: "Hello, world!" });
  event.trigger(function(){}); // you can also pass functions
  event.trigger({ message: "Hello, world!" }, { from: "component1", type: "info" }); // trigger with meta 
  unsubscribe(); // unsubscribe from the event  

Listening to events in a component

  useOnEvent([event], (data, meta) => {
    console.log(data, meta);
    /// gets called when the event is triggered
  });

Channels

  • createChannel(): Creates a new channel.
  • useChannel(channel, onPublishCallback): Subscribes to a channel and calls a callback when the channel is triggered.
  • channel.publish(data, meta): Publishes a message to the channel.
  • channel.getState(): Returns the last state of the channel.
  • channel.getSubscriptionsCount(): Returns the number of active subscriptions to the channel.
  const channel = createChannel();
  const unsubscribe = channel.subscribe((data, meta) => {
    console.log(data, meta);
  });
  channel.publish({ message: "Hello, world!" });
  channel.publish({ message: "Hello, world!" }, { from: "component1", type: "info" }); // trigger with meta 
  unsubscribe(); // unsubscribe from the channel  

Accessing channels in a component

  useChannel(channel, (data, meta) => {
    console.log(data, meta);
    /// gets called when the channel is triggered
  });

License

This utility is open-source and available under the MIT License.