1.0.1 • Published 5 years ago

@strong-roots-capital/observe v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

observe Build status npm version codecov

Observe and react to an EventSource

Install

npm install @strong-roots-capital/observe

Use

import observe from '@strong-roots-capital/observe'
import { EventSource } from '@strong-roots-capital/event-source'

function callback() {
    console.log('In callback')
}

const es = new EventSource()
const observer = observe(es,callback)

es.emit('eventA')
//=> In callback

es.emit('eventB')
//=> In callback

observer.dispose()

es.emit('eventA')

Related

Acknowledgments