nano-pubsub
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

nano-pubsub

Tiny (<0.5 kb) publish/subscribe

Install

npm install nano-pubsub

Usage example

import createPubsub from 'nano-pubsub'

const events = createPubsub()

const unsubscribe = events.subscribe(value => {
  console.log('got value:', value)
})

events.publish('Hello')
// => 'got value: Hello'

events.publish('World')
// => 'got value: World'

unsubscribe()

events.publish('Something')

// ...nothing

Package Sidebar

Install

npm i nano-pubsub

Weekly Downloads

157,002

Version

3.0.0

License

MIT

Unpacked Size

6.99 kB

Total Files

9

Last publish

Collaborators

  • bjoerge