Skip to content

Instantly share code, notes, and snippets.

View armanozak's full-sized avatar

Levent Arman Özak armanozak

View GitHub Profile
@armanozak
armanozak / rxjs-6_retry.ts
Created May 3, 2021 09:16
[What's New in RxJS 7] RxJS 6 retry #blog #rxjs
import { defer, from } from "rxjs";
import { retry, tap } from "rxjs/operators";
const values = ["_", 0, 1, 0, 2, 0, 3, 0, 0, 0, 4];
defer(() => {
values.shift();
return from(values);
})
.pipe(
@armanozak
armanozak / rxjs-7_timeout-with.ts
Created May 3, 2021 09:15
[What's New in RxJS 7] RxJS 7 timeout with #blog #rxjs
import { timer } from "rxjs";
import { timeout } from "rxjs/operators";
timer(5000, 1000)
.pipe(timeout({ first: 2000, with: _ => of("timeout") }))
.subscribe(console.log);
// (after ~2s) timeout
@armanozak
armanozak / rxjs-6_timeoutWith.ts
Created May 3, 2021 09:15
[What's New in RxJS 7] RxJS 6 timeoutWith #blog #rxjs
import { timer } from "rxjs";
import { timeoutWith } from "rxjs/operators";
timer(5000, 1000)
.pipe(timeoutWith(2000, of("timeout")))
.subscribe(console.log);
// (after ~2s) timeout
@armanozak
armanozak / rxjs-7_timeout.ts
Created May 3, 2021 09:14
[What's New in RxJS 7] RxJS 7 timeout #blog #rxjs
import { timer } from "rxjs";
import { timeout } from "rxjs/operators";
const count$ = timer(3000, 2000);
count$
.pipe(timeout({ first: 5000, each: 1000 }))
.subscribe({ next: console.log, error: console.error });
// (after ~3s) 0
// (after ~1s) Error: Timeout has occurred
@armanozak
armanozak / rxjs-6_timeout.ts
Created May 3, 2021 09:14
[What's New in RxJS 7] RxJS 6 timeout #blog #rxjs
import { concat, partition, timer } from "rxjs";
import { first, share, timeout } from "rxjs/operators";
const count$ = timer(3000, 2000).pipe(share());
const [first$, rest$] = partition(count$, (_, index) => index === 0);
concat(
first$.pipe(
timeout(5000),
@armanozak
armanozak / rxjs-7_concatWith.ts
Created May 3, 2021 09:10
[What's New in RxJS 7] RxJS 7 concatWith #blog #rxjs
import { interval } from "rxjs";
import { concatWith, map } from "rxjs/operators";
const count1To5$ = interval(1000).pipe(
take(5),
map(i => i + 1)
);
const count6To9$ = interval(1000).pipe(
take(4),
@armanozak
armanozak / rxjs-6_concat.ts
Created May 3, 2021 09:09
[What's New in RxJS 7] RxJS 6 concat #blog #rxjs
import { interval } from "rxjs";
import { concat, map } from "rxjs/operators";
const count1To5$ = interval(1000).pipe(
take(5),
map(i => i + 1)
);
const count6To9$ = interval(1000).pipe(
take(4),
@armanozak
armanozak / rxjs-7_raceWith.ts
Created May 3, 2021 09:08
[What's New in RxJS 7] RxJS 7 raceWith #blog #rxjs
import { interval } from "rxjs";
import { map, raceWith } from "rxjs/operators";
const count1To5$ = interval(1000).pipe(
take(5),
map(i => i + 1)
);
const count6To9$ = interval(1000).pipe(
take(4),
@armanozak
armanozak / rxjs-6_race.ts
Created May 3, 2021 09:07
[What's New in RxJS 7] RxJS 6 race #blog #rxjs
import { interval } from "rxjs";
import { map, race } from "rxjs/operators";
const count1To5$ = interval(1000).pipe(
take(5),
map(i => i + 1)
);
const count6To9$ = interval(1000).pipe(
take(4),
@armanozak
armanozak / rxjs-7_zipWith.ts
Created May 3, 2021 09:06
[What's New in RxJS 7] RxJS 7 zipWith #blog #rxjs
import { interval } from "rxjs";
import { map, zipWith } from "rxjs/operators";
const count1To5$ = interval(1000).pipe(
take(5),
map(i => i + 1)
);
const count6To9$ = interval(1000).pipe(
take(4),