import type { CoreSetup , Plugin } from 'src/core/public' ; import ReactDOM from 'react-dom' ; import React from 'react' ; import { debounce , filter , first } from 'rxjs/operators' ; import { timer } from 'rxjs' ; export class TestEndpointsPlugin implements Plugin { public setup ( core ) { core . http . anonymousPaths . register ( '/authentication/app' ) ; const networkIdle$ = core . http . getLoadingCount$ ( ) . pipe ( debounce ( ( ) => timer ( 3000 ) ) , filter ( ( count ) => count === 0 ) , first ( ) ) ; core . application . register ( { id : 'authentication_app' , title : 'Authentication app' , appRoute : '/authentication/app' , chromeless : true , async mount ( { element } ) { networkIdle$ . toPromise ( ) . then ( ( ) => { ReactDOM . render ( < div data - test - subj = "testEndpointsAuthenticationApp" > Authenticated ! < /div>, element); } ) ; return ( ) => ReactDOM . unmountComponentAtNode ( element ) ; } , } ) ; } public start ( ) { } public stop ( ) { } }