@strong-roots-capital/observe
v1.0.1
Published
Observe and react to an EventSource
Downloads
3
Readme
observe
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')