import { Observable } from 'rxjs' ; import { distinctUntilChanged , pairwise , startWith , takeUntil , map } from 'rxjs/operators' ; import { ServiceStatus } from './types' ; export const getOverallStatusChanges = ( overall$ , stop$ ) => { return overall$ . pipe ( takeUntil ( stop$ ) , distinctUntilChanged ( ( previous , next ) => { return previous . level . toString ( ) === next . level . toString ( ) ; } ) , startWith ( undefined ) , pairwise ( ) , map ( ( [ oldStatus , newStatus ] ) => { if ( oldStatus ) { return `Kibana is now ${ newStatus ! . level . toString ( ) } (was ${ oldStatus ! . level . toString ( ) })` ; } return `Kibana is now ${ newStatus ! . level . toString ( ) }` ; } ) ) ; } ;