@strong-roots-capital/observable
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

Package Sidebar

Install

npm i @strong-roots-capital/observable

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

20.3 kB

Total Files

11

Last publish

Collaborators

  • amchelle
  • hamroctopus