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_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_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_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_combineLatestWith.ts
Created May 3, 2021 09:04
[What's New in RxJS 7] RxJS 7 combineLatestWith #blog #rxjs
import { interval } from "rxjs";
import { combineLatestWith, 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_combineLatest.ts
Created May 3, 2021 09:04
[What's New in RxJS 7] RxJS 6 combineLatest #blog #rxjs
import { interval } from "rxjs";
import { combineLatest, 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_combineLatest-dictionary.ts
Created May 3, 2021 09:03
[What's New in RxJS 7] Observable dictionaries in RxJS 7 combineLatest #blog #rxjs
import { combineLatest, interval } from "rxjs";
import { 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_forkJoin-dictionary.ts
Created May 3, 2021 09:02
[What's New in RxJS 7] Observable dictionaries in RxJS 6 forkJoin #blog #rxjs
import { forkJoin, interval } from "rxjs";
import { 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_alternative_EmptyError_constructor.ts
Created May 3, 2021 09:01
[What's New in RxJS 7] An alternative available for ES6+ builds #blog #rxjs
export class EmptyError extends Error {
constructor() {
super("no elements in sequence");
this.name = "EmptyError";
}
}
@armanozak
armanozak / rxjs-7_createErrorClass.ts
Created May 3, 2021 09:00
[What's New in RxJS 7] How EmptyError is created in RxJS #blog #rxjs
export const EmptyError: EmptyErrorCtor = createErrorClass(
_super =>
function EmptyErrorImpl(this: any) {
_super(this);
this.name = "EmptyError";
this.message = "no elements in sequence";
}
);
@armanozak
armanozak / rxjs-7_detect-empty-error.ts
Created May 3, 2021 08:58
[What's New in RxJS 7] RxJS 7 detect empty error with EmptyError #blog #rxjs
import { EMPTY, EmptyError, lastValueFrom } from "rxjs";
lastValueFrom(EMPTY).catch(err => console.log(err instanceof EmptyError));
// (asynchronously) true