Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drublic/pubsub
A JS pub/sub implementation
https://github.com/drublic/pubsub
events javascript pubsub
Last synced: about 2 months ago
JSON representation
A JS pub/sub implementation
- Host: GitHub
- URL: https://github.com/drublic/pubsub
- Owner: drublic
- License: mit
- Created: 2014-12-15T22:04:08.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-19T14:48:08.000Z (almost 8 years ago)
- Last Synced: 2024-11-01T12:35:52.605Z (about 2 months ago)
- Topics: events, javascript, pubsub
- Language: JavaScript
- Size: 11.7 KB
- Stars: 43
- Watchers: 7
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PubSub - vanilla-pubsub
PubSub is a JS implementation of a publication/subscription pattern in JS
using vanilla JS.[![Build Status](https://api.travis-ci.org/drublic/PubSub.svg)](http://travis-ci.org/drublic/PubSub)
[![Coverage Status](https://coveralls.io/repos/drublic/PubSub/badge.svg?branch=master)](https://coveralls.io/r/drublic/PubSub?branch=master)## Install
npm install --save vanilla-pubsub
## Usage
Subscribe
PubSub.subscribe('App.loaded', function () {});
PubSub.subscribe('App.done', [App.loadStack, App.clock]);
PubSub.subscribe(['App.undo', 'App.redo'], App.change);Unsubscribe
PubSub.unsubscribe('App.done', App.loadStack);
PubSub.unsubscribe(['App.undo', 'App.redo'], App.change);Publish
PubSub.publish('App.loaded');
PubSub.publish('App.loaded', { data: App.data });
PubSub.publish(['App.undo', 'App.redo']);