import { defer , Observable } from 'rxjs' ; import { filter , finalize , tap } from 'rxjs/operators' ; export function isNonNullable < T > ( ) { return ( source$ ) => source$ . pipe ( filter ( ( v ) : v is NonNullable < T > => v !== null && v !== undefined ) ) ; } export function finalizeLast < T > ( callback ) { return ( source$ ) => defer ( ( ) => { let lastValue ; return source$ . pipe ( tap ( value => ( lastValue = value ) ) , finalize ( ( ) => { if ( lastValue ) callback ( lastValue ) ; } ) ) ; } ) ; }