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

skelenode-dispatcher

v0.0.1

Published

A pub/sub library to dispatch events across all parts of an app, both front-end and back-end

Downloads

2

Readme

Skelenode Dispatcher

This is a Skelenode component to manage publish/subscribe events across all parts of your application. When used in conjunction with Skelenode API, you can also listen for events from the front-end of your application. Because of it's use with redis it can communicate across all nodes in a cluster with no issues.

The dispatched events do not contain any data. This means that we can keep it lean and not have to worry about permissions or access rights. When a callback is fired, it's the responsability of the listener to respond to the event appropriately.

For example, your front-end has a list of restaurants. It can listen to an event like 'change:restaurant' and when there is a change to the list of restaurants, the server will emit the event 'change:restaurant'. The client will then fire off a request to the server to fetch a new list of restaurants.

Requirements

  • You must have a redis server that you can connect to

Installation

npm install skelenode-dispatcher

Usage

var dispatcher = require('skelenode-dispatcher');

// start the dispatcher which connects to redis
dispatcher.start(redisPort, redisHost, redisPassword, debug);

// subscribe to an event
dispatcher.subscribe('my-event', function() {
	console.log('My Event!');
});

// publish an event
dispatcher.publish('my-event')

Methods

start(port, host, password, debug)

Connects to redis on the given port, host, and optional password. The debug argument is a boolean which will output logs to the server to help troubleshoot what's happening.

This only needs to be called once when your application starts.

attach(context)

Attaches the dispatcher to a particular context, adding the "dispatcher" namespace to it.

After being attached, you can context.dispatcher.subscribe(event, callback) or context.dispatcher.unsubscribe(event, callback).

attached(context)

Determines whether or not the dispatcher has been attached to the specified context.

detach(context)

Detaches the dispatcher from a particular context, remove the "dispatcher" namespace from it and stopping all subscriptions.

subscribe(event, callback)

Subscribes a callback to a particular event. Anytime this event is published to a dispatcher, on any node in the system, the callback will be executed.

unsubscribe(event, callback)

Unsubscribes a callback from a particular event.

publish(event)

Publishes an event across the cluster. All dispatchers that are listening for this event will notify their attached contexts.

Contributing

Open a pull request with plenty of well-written instructions on what you are submitting and why you are submitting it