Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 554 Bytes

README.md

File metadata and controls

38 lines (27 loc) · 554 Bytes

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