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

strong-roots-capital/event-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

event-source Build status npm version codecov

Reduction of an EventEmitter to a composable event-stream

Install

npm install @strong-roots-capital/event-source

Use

import { eventSource } from '@strong-roots-capital/event-source'
let a = new EventSource()
let b = new EventSource()
let es = a.merge(b.map((n: number) => 'I mapped this! ' + n))

es.on('event', (event: string | symbol, ...args: any[]) => {
    console.log(event, args)
})

a.emit('unmapped', 1)
//=> unmapped [ 1 ]

b.emit('mapped', 1)
//=> mapped [ 'I mapped this! 1' ]

Related

Acknowledgments