Skip to content

Instantly share code, notes, and snippets.

@vorant94
Last active September 7, 2023 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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 != null),
map(value => value!)
);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment