import { MonoTypeOperatorFunction , queueScheduler , scheduled , from } from 'rxjs' ; import { concatAll , distinctUntilChanged , skip } from 'rxjs/operators' ; export function distinctUntilChangedWithInitialValue < T > ( initialValue , compare ? ) { return ( input$ ) => scheduled ( [ isPromise ( initialValue ) ? from ( initialValue ) : [ initialValue ] , input$ ] , queueScheduler ) . pipe ( concatAll ( ) , distinctUntilChanged ( compare ) , skip ( 1 ) ) ; } function isPromise < T > ( value ) { return ( ! ! value && typeof value === 'object' && 'then' in value && typeof value . then === 'function' && ! ( 'subscribe' in value ) ) ; }