npm install typescript-pubsub
or
git clone https://github.com/vbrdnk/typescirpt-pubSub.git
import { PubSub } from 'your_relative_path_to_package';
Use available static methods for subscribing, unsubscribing and emitting events from PubSub class
Adds eventName: Function[]
property to static events
object and pushes callbackFunc
to this array.
Checks for eventName property in static events
and if exits checks for all functions listed in this property. If callback function exists in an array, removes it, so it won't be execuded
Checks for eventName property in static events
and executes all functions inside eventName property with given data
Holds all events that are added with PubSub.subscribe(eventName: string, callbackFunc: Function): void
method as well as all functions that should be executed when some data is emitted with specific event