Skip to content

Instantly share code, notes, and snippets.

@vorant94
Last active July 13, 2024 08:05
Show Gist options
  • Save vorant94/08c16809ec61185f8d72d355413627d2 to your computer and use it in GitHub Desktop.
Save vorant94/08c16809ec61185f8d72d355413627d2 to your computer and use it in GitHub Desktop.
import { filter, map, Observable, OperatorFunction } from 'rxjs';
export function nonNullable<T>(): OperatorFunction<T, NonNullable<T>> {
return function (source$: Observable<T>): Observable<NonNullable<T>> {
return source$.pipe(
filter((value): value is T => value != null)
);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment