Skip to content

thisIsTheWei/ES6.PubSub.Singleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

PubSub Singleton Class

A lightweight es6 PubSub class (Singleton).

Usage

Import the PubSub singleton

import PubSub from './PubSub.js';

Subscribe to new event with a custom callback

const topic = PubSub.subscribe( 'event', callback );
// or if you don't need to unsubscribe
PubSub.subscribe('event', callback)

Publish/broadcast an event and pass optional arguments

PubSub.publish('event', {data})

Unsubscribe from a specific topic

PubSub.unsubscribe(topic );

About

A lightweight es6 PubSub class (Singleton).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published