import { Observable , merge , of , partition } from 'rxjs' ; import { filter , repeatWhen , shareReplay , takeUntil } from 'rxjs/operators' ; import { ObMasterLayoutHeaderService } from './master-layout-header/master-layout-header.service' ; import { ObEMasterLayoutEventValues , ObIMasterLayoutEvent } from './master-layout.model' ; export function scrollEnabled ( service ) { const [ enabled$ , disabled$ ] = partition ( merge ( service . configEvents$ , of ( { name : ObEMasterLayoutEventValues . HEADER_REDUCE_ON_SCROLL , value : service . reduceOnScroll } ) ) . pipe ( filter ( ( evt ) => evt . name === ObEMasterLayoutEventValues . HEADER_REDUCE_ON_SCROLL ) , shareReplay ( { refCount : true , bufferSize : 1 } ) ) , ( evt ) => evt . value ) ; return function < T > ( source ) : Observable < T > { return source . pipe ( takeUntil ( disabled$ ) , repeatWhen ( ( ) => enabled$ ) ) ; } ; }