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 { defer } = require('rxjs'); | |
const { retryWhen, tap, delay } = require('rxjs/operators'); | |
defer(() => mockRequest()).pipe( | |
retryWhen(errors$ => | |
errors$.pipe( | |
tap(rxObserver('retries')), | |
delay(10) |
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 } = require('rxjs'); | |
const { map, tap, retryWhen, delayWhen } = require('rxjs/operators'); | |
const source$ = | |
timer(0, 100).pipe( | |
map(val => { | |
if (val == 1) { | |
throw 'Err'; | |
} |
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 { Subject, of } = require('rxjs'); | |
const { switchMap, delay } = require('rxjs/operators'); | |
const subject = new Subject(0); | |
const result$ = subject | |
.pipe( | |
switchMap(value => | |
// switchMap to a delayed value |
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 } = require('rxjs'); | |
const { concatMap } = require('rxjs/operators'); | |
// our source$ will emit values at | |
// 0, 100, 200, 300... | |
const source$ = timer(0, 100); | |
const concatMap$ = source$.pipe( |
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, EMPTY, pipe } = require('rxjs'); | |
const { zip, startWith, pairwise, switchMap, filter } = require('rxjs/operators'); | |
// create a source using values | |
const values$ = from([ 5, 10, 20, 10, 5, 20, 0, 5 ]); | |
const source$ = timer(0, 10).pipe( | |
zip(values$, (_,x)=>x) | |
); |
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, EMPTY } = require('rxjs'); | |
const { zip, debounceTime, map, scan, distinctUntilChanged } = require('rxjs/operators'); | |
// create a source using values | |
const values$ = from([ 5, 10, 20, 10, 5, 20, 0, 5, 30 ]); | |
const source$ = timer(0, 10).pipe( | |
zip(values$, (_,x)=>x) | |
); |
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, EMPTY } = require('rxjs'); | |
const { zip, startWith, pairwise, switchMap } = require('rxjs/operators'); | |
// create a source using values | |
const values$ = from([ 5, 10, 20, 10, 5, 20, 0, 5 ]); | |
const source$ = timer(0, 10).pipe( | |
zip(values$, (_,x)=>x) | |
); |
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, palette } = require('api/v0.3'); | |
const { of } = require('rxjs'); | |
const { switchMap, delay} = require('rxjs/operators'); | |
const fns = | |
[ (value) => of(value + 1).pipe(delay(100)) | |
, (value) => of(value + 3).pipe(delay(100)) | |
, (value) => of(value + 5).pipe(delay(100)) | |
] |
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, of, throwError } = require('rxjs'); | |
const { merge, map, tap, take, finalize, retryWhen, switchMap } = require('rxjs/operators'); | |
const sourceObserver = rxObserver('Source'); | |
const errorsObserver = rxObserver('Errors'); | |
const resultObserver = rxObserver('Result'); | |
timer(10, 10).pipe( | |
map(x => { |
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, combineLatest } = require('rxjs'); | |
const { map, take } = require('rxjs/operators'); | |
const timerOne = timer(100, 400); | |
const timerTwo = timer(200, 400); | |
const timerThree = timer(300, 400); | |
timerOne.subscribe(rxObserver()); | |
timerTwo.subscribe(rxObserver()); |