Last active
October 6, 2022 17:27
-
-
Save klinki/309a548cbed632282e2ffc325e0d385f to your computer and use it in GitHub Desktop.
Marbles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { rxObserver } = require('api/v0.3'); | |
const { timer, from, of, concat } = require('rxjs'); | |
const { filter, tap, concatMap, take, map, debounceTime, interval, delay, first } = require('rxjs/operators'); | |
// Try chaning 0 to baa | |
matching = '0'; | |
$urls = from(['a', 'b', 'c']) | |
.pipe( | |
tap(rxObserver('urls')), | |
concatMap(x => of(x + 'a').pipe(delay(1), tap(rxObserver('urls with delay')))), | |
tap(rxObserver('with delay')), | |
filter(x => x === 'ba'), | |
concatMap(x => of(x + 'a')), | |
first(), | |
tap(rxObserver('filtered urls')), | |
); | |
$allUrls = concat(of('0'), $urls, of('1')); | |
$allUrls.pipe( | |
tap(rxObserver('all urls with pre-and-post')), | |
concatMap(item => of(item).delay(1)), | |
tap(rxObserver('resolved urls')), | |
first(x => x == matching), | |
).subscribe(rxObserver('result')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment