callbag-from-events
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

callbag-from-events

Create a Callbag from:

  • any object with on/off methods,
  • a DOM EventTarget,
  • or a Node.JS EventEmitter.
import fromEvents from 'callbag-from-events'
import { map, filter } from 'callbag-basics'
import { ipcMain } from 'electron'
import { nodeEvents } from './server'

const chatReceived = fromEvents(nodeEvents, 'chat-received')
  |> filter(message => message.length > 0)
  |> map(message => ({ chat: message }))

const buttonClicked = fromEvents(document.getElementById('start'), 'click')

const processCompleted = fromEvents(ipcMain, 'process-completed')

Readme

Keywords

Package Sidebar

Install

npm i callbag-from-events

Weekly Downloads

24

Version

1.1.0

License

MIT

Unpacked Size

3.63 kB

Total Files

4

Last publish

Collaborators

  • sartaj