1.0.0 • Published 6 years ago

callbag-from-event-pattern v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

callbag-from-event-pattern

Callbag source factory from addHandler and removeHandler pair.

Example

import forEach from 'callbag-for-each'
import fromEventPattern from 'callbag-from-event-pattern'
import map from 'callbag-map'
import pipe from 'callbag-pipe'

const addHandler = handler => {
  document.addEventListener('click', handler)
}

const removeHandler = handler => {
  document.removeEventListener('click', handler)
}

pipe(
  fromEventPattern(addHandler, removeHandler),
  map(({ clientX: x, clientY: y }) => ({ x, y })),
  forEach(coord => {
    // will log coordinate of each click
    console.log(coord)
  }),
)
1.0.0

6 years ago

0.0.0

6 years ago