Package Exports
- pull-switch-map
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-switch-map) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
pull-switch-map
npm install --save pull-switch-mapThe pull-stream equivalent to RxJS's switchMap operator.
Description
In other words, this is essentially a map-and-flatten operation, but treats concurrency so that the outer stream is pulled concurrently at the same time as the inner stream is pulled, and once a new outer value is received, the current inner stream is aborted and swapped with the new inner stream.
Marble diagram:
interval(1000)
------------0------------1------------2------------3--------...
switchMap(x => interval(350))
---------------0---1---2----0---1---2----0---1---2----0---1-...Arguments to switchMap(fn):
fn: the mapping function that takes the value from the outer pull-stream and returns a new (inner) pull-stream
Usage
const pull = require('pull-stream')
const switchMap = require('pull-switch-map')
pull(
somesource(),
switchMap(x => pull.values([x])),
pull.drain(i => console.log(i))
)License
MIT