Skip to content

Latest commit

 

History

History

sampleon

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

flyd-sampleon

Sample from the second stream every time an event occurs on the first stream.

Graph

a:              {--t--t--t-------t}
b:              {---1---2---3---4-}
sampleOn(a, b): {-----1--2-------4}

Signature

Stream a -> Stream b -> Stream b

Usage

const sampleOn = require('flyd/module/sampleon')

const sample = flyd.stream()
const on = flyd.stream()
const result = sampleOn(on, sample)

on(true)
result() // undefined

sample(1)
on(true)
result() // 1

sample(2)
sample(3)
on(true)
result() // 3