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-7_custom-error-call-stack.ts
Created May 3, 2021 09:22
[What's New in RxJS 7] Custom errors get call stack back in RxJS 7 #blog #rxjs
import { EMPTY } from "rxjs";
import { first } from "rxjs/operators";
EMPTY.pipe(first()).subscribe({ error: console.warn });
// (synchronously) EmptyErrorImpl
// v6.6.7 has no call stack, but v7 does
@armanozak
armanozak / rxjs-7_connectable-resetOnDisconnect.ts
Created May 4, 2021 11:13
[What's New in RxJS 7] RxJS 7 connectable resetOnDisconnect #blog #rxjs
import { connectable, interval, merge, of, Subject, zip } from "rxjs";
import { filter, map } from "rxjs/operators";
const chars$ = zip(interval(1000), of("A", "b", "C", "D", "e", "f", "G")).pipe(
map(([, char]) => char)
);
const connectableChars$ = connectable(chars$, {
connector: () => new Subject(),
resetOnDisconnect: true
});
@armanozak
armanozak / split-concat.ts
Created May 10, 2023 07:12
Split & Concat Types w/ Delimiter
/*
* Note: This is just for fun.
*/
type Split<T extends string, Delimiter extends string = ""> =
"" extends T
? []
: T extends `${infer Head}${Delimiter}${infer Tail}`
? [Head, ...Split<Tail, Delimiter>]
: [T];