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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ez-channel

v1.2.7

Published

Lightweight library to create custom events and trigger and subscribe them from everywhere. Works standalone or with other frameworks like react.js or vue.js

Downloads

4

Readme

Lightweight library to create custom events and trigger and subscribe them from everywhere. Works standalone or with other frameworks like react.js or vue.js

What can this program do ?

Sometimes you need a simple implementation to create global channels and subscribe them from other pieces of code, components or stuff like that. With ez-channel it is easy ;-)

Benefit

If you want to define, trigger and process events in different files, this library can help you. You only need to include ez-channel in your files where you want to work with your custom events.

Installation

Package is available here: https://www.npmjs.com/package/ez-channel

  npm i ez-channel

Usage

Just include it into your web or server project

node

  const Channel = require('ez-channel');

web

  import {Channel} from 'ez-channel';

or you can include the transpiled script from dist folder.

create channel

A channel is that object that manage all events and subscriptions for you. To create a new channel, just do it like follow.

  Channel.create("myAwesomeChannel");

subscribe

Subscribe gives you all the functions that you need to trigger and listen for events. See example below.

  const channel = Channel.subscribe();

create and listen to event

If you want to create an event, uhm let´s say "youAreAwesome" and you want listen to that, just do it like follow.

  channel.on("myAwesomeChannel", "youAreAwesome", function() {
      console.log("someone says your are awesome");
    });

dispatch event

If you want to dispatch an events, just simple do it like follow.

  channel.send("myAwesomeChannel", "youAreAwesome");

dispatch and listen with data

Of course it is possible the send and receive data by "on" and "send". See example below:

  channel.send("myAwesomeChannel", "youAreAwesome",{isAwesome: true});
  channel.on("myAwesomeChannel", "youAreAwesome", function(obj) {
      if(obj.isAwesome) {
        console.log("you are awesome");
      }
    });

remove channel

Maybe it make sometimes sense to remove a channel. You can do it like follow.

  channel.remove("myAwesomeChannel");

Licence

Apache 2.0

Happy using and keep coding =)