Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

strong-roots-capital/observe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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