Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Andarist/callbag-pull-when
👜 Callbag operator that pulls from source when provided listenable emits.
https://github.com/Andarist/callbag-pull-when
callbag callbags sampling
Last synced: 3 months ago
JSON representation
👜 Callbag operator that pulls from source when provided listenable emits.
- Host: GitHub
- URL: https://github.com/Andarist/callbag-pull-when
- Owner: Andarist
- Created: 2018-04-03T12:04:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-14T13:02:28.000Z (over 5 years ago)
- Last Synced: 2024-10-26T01:37:51.401Z (3 months ago)
- Topics: callbag, callbags, sampling
- Language: JavaScript
- Size: 3.91 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-callbags - pull-when
README
# callbag-pull-when
Callbag operator that pulls (samples) from source when provided listenable emits. It's [`sampleWhen`](https://github.com/Andarist/callbag-sample-when)'s version - this one works with pullable source, while the other one works with listenables.
It works similar to [Rx's sample](http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-sample).
## Example
```js
import forEach from 'callbag-for-each'
import fromIter from 'callbag-from-iter'
import pipe from 'callbag-pipe'
import pullWhen from 'callbag-pull-when'
import timer from 'callbag-timer'pipe(
fromIter([10, 20, 30, 40]),
pullWhen(timer(1000, 2000)),
forEach(value => {
// will log 10 after 1 second, and 20, 30, 40 after 2 seconds from each other
console.log(value)
}),
)
```