1.0.0 • Published 6 years ago

xstream-switch-last v1.0.0

Weekly downloads
15
License
MIT
Repository
-
Last release
6 years ago

xstream-switch-last

Transform a stream of stream to a stream by always taking value from the lastest one.

Marble diagram:

--+--------+---------------
  \        \
   \       ----1----2---3--
   --a--b----c----d--------
    flattenConcurrently
-----a--b------1----2---3--
const stream = xs.merge(
  xs.of(xs.periodic(100)),
  xs.of(1).compose(delay(350)).mapTo(xs.periodic(100).take(3).map(i => i + 10)),
)
.compose(switchLast);

// [0,1,2,10,11,12]