Skip to content

Files

Latest commit

Sep 11, 2021
ff979aa · Sep 11, 2021

History

History
31 lines (21 loc) · 431 Bytes

README.md

File metadata and controls

31 lines (21 loc) · 431 Bytes

nano-pubsub

Tiny (<0.5 kb) publish/subscribe

Install

npm install nano-pubsub

Usage example

const Pubsub = require('nano-pubsub')

const events = Pubsub()

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