import React from 'react' ; import ReactDOM from 'react-dom' ; import type { ExpressionsService , ExpressionsServiceSetup } from 'src/plugins/expressions' ; import { AppMountParameters , AppNavLinkStatus , CoreSetup , Plugin } from '../../../src/core/public' ; import type { DeveloperExamplesSetup } from '../../developer_examples/public' ; import { App , ExpressionsContext } from './app' ; import { countEvent , getEvents , pluck } from './functions' ; interface SetupDeps { developerExamples : DeveloperExamplesSetup ; expressions : ExpressionsServiceSetup ; } export class PartialResultsExamplePlugin implements Plugin < void , void , SetupDeps > { private expressions ? : ExpressionsService ; setup ( { application } , { expressions , developerExamples } ) { this . expressions = expressions . fork ( ) ; this . expressions . registerFunction ( countEvent ) ; this . expressions . registerFunction ( getEvents ) ; this . expressions . registerFunction ( pluck ) ; application . register ( { id : 'partialResultsExample' , title : 'Partial Results Example' , navLinkStatus : AppNavLinkStatus . hidden , mount : async ( { element } ) => { ReactDOM . render ( < ExpressionsContext . Provider value = { this . expressions } > < App /> < /ExpressionsContext.Provider>, element); return ( ) => ReactDOM . unmountComponentAtNode ( element ) ; } , } ) ; developerExamples . register ( { appId : 'partialResultsExample' , title : 'Partial Results Example' , description : 'Learn how to use partial results in the expressions plugin.' , } ) ; } start ( ) { return { } ; } stop ( ) { } }