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

strong-roots-capital/observable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Observable Build status npm version codecov

Capable of observing and reacting to EventSources

Install

npm install @strong-roots-capital/observable

Use

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

class MyObservable extends Observable {
    handleEvent(event: string | symbol, ...args: any[]) {
        console.log(`In handleEvent with event '${event}' and arguments ${args}`)
    }
}

const es = new EventSource()
const myobservable = new MyObservable()
myobservable.source = es

es.emit('some-event', 1, 2, 3)
//=> In handleEvent with event 'some-event' and arguments [1, 2, 3]

Related

Acknowledgments