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_merge.ts
Created May 3, 2021 09:05
[What's New in RxJS 7] RxJS 6 merge #blog #rxjs
import { interval } from "rxjs";
import { map, merge } 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_mergeWith.ts
Created May 3, 2021 09:05
[What's New in RxJS 7] RxJS 7 mergeWith #blog #rxjs
import { interval } from "rxjs";
import { map, mergeWith } 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_zip.ts
Created May 3, 2021 09:06
[What's New in RxJS 7] RxJS 6 zip #blog #rxjs
import { interval } from "rxjs";
import { map, zip } 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),
@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_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_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_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_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_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