1.0.0 • Published 6 years ago

callbag-sample-when v1.0.0

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

callbag-sample-when

Callbag operator that samples from source when provided listenable emits. Works like Rx's sample.

Example

import fromEvent from 'callbag-from-event'
import forEach from 'callbag-for-each'
import map from 'callbag-map'
import merge from 'callbag-merge'
import pipe from 'callbag-pipe'
import sample from 'callbag-sample'

pipe(
  merge(
    map(() => false)(fromEvent(element, 'mousedown')),
    map(() => true)(fromEvent(element, 'mousemove')),
  ),
  sample(fromEvent(element, 'mouseup')),
  forEach(isDragging => {
    console.log('Were you dragging?', isDragging)
  }),
)
1.0.0

6 years ago