Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Andarist/callbag-exhaust-map
👜 Callbag operator that maps to inner source and ignores other values until that source completes.
https://github.com/Andarist/callbag-exhaust-map
callbag callbags
Last synced: 16 days ago
JSON representation
👜 Callbag operator that maps to inner source and ignores other values until that source completes.
- Host: GitHub
- URL: https://github.com/Andarist/callbag-exhaust-map
- Owner: Andarist
- Created: 2018-04-26T13:33:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-11T21:30:23.000Z (about 6 years ago)
- Last Synced: 2024-10-20T06:22:54.710Z (22 days ago)
- Topics: callbag, callbags
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-callbags - exhaust-map
README
# callbag-exhaust-map
Callbag operator that maps to inner source and ignores other values until that source completes.
## Example
```js
import debounce from 'callbag-debounce'
import exhaustMap from 'callbag-exhaust-map'
import filter from 'callbag-filter'
import forEach from 'callbag-for-each'
import fromEvent from 'callbag-from-event'
import fromPromise from 'callbag-from-promise'
import map from 'callbag-map'
import pairwise from 'callbag-pairwise'
import pipe from 'callbag-pipe'pipe(
fromEvent(window, 'scroll'),
map(({ target: { clientHeight, scrollHeight, scrollTop } }) => ({
clientHeight,
scrollHeight,
scrollTop,
})),
pairwise,
debounce(200),
filter(([prev, current]) => {
const scrollingDown = prev.scrollTop < current.scrollTop
const nearBottom =
(current.scrollTop + current.clientHeight) / current.scrollHeight > 0.9
return scrollingDown && nearBottom
}),
exhaustMap(() => fromPromise(fetchItems())),
forEach(items => {
console.log(items)
}),
)
```