0.0.4 • Published 2 years ago

jpubsub v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

jpubsub - Simple Javascript PubSub

Install

yarn add jpubsub
# or
npm install -S jpubsub
import makePublisher from 'jpubsub'
import type {Subscriber} from 'jpubsub' // generic type Subscriber<T>
// or
const makePublisher = require('jpubsub')

// define a subscriber
const subscriber: Subscriber<string> = (data) => {
		console.log(data)
}
// create a publisher
const pubsliher = makePubsliher<string>()
// subscribe
const unsubscribe = publisher.subscribe(subscriber)
// publish
publisher.publish('hello')
// unsubscribe
unsubscribe()
0.0.3

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago