Skip to content

👜Create a Callbag from any object with on/off methods, a DOM EventTarget, or a Node.JS EventEmitter.

Notifications You must be signed in to change notification settings

sartaj/callbag-from-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')

About

👜Create a Callbag from any object with on/off methods, a DOM EventTarget, or a Node.JS EventEmitter.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published