Skip to content

👜 Callbag operator that samples from source when provided listenable emits.

Notifications You must be signed in to change notification settings

Andarist/callbag-sample-when

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 sampleWhen from 'callbag-sample-when'

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

About

👜 Callbag operator that samples from source when provided listenable emits.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published