import { TypeOf } from '@osd/config-schema' ; import { CoreSetup , Plugin , PluginInitializerContext } from 'opensearch-dashboards/server' ; import { registerRoutes } from './routes' ; import { ConfigSchema , configSchema } from '../../config' ; export class AutocompleteService implements Plugin < void > { private valueSuggestionsEnabled : boolean = true ; constructor ( private initializerContext ) { initializerContext . config . create < TypeOf < typeof configSchema > > ( ) . subscribe ( ( configUpdate ) => { this . valueSuggestionsEnabled = configUpdate . autocomplete . valueSuggestions . enabled ; } ) ; } public setup ( core ) { if ( this . valueSuggestionsEnabled ) registerRoutes ( core , this . initializerContext . config . legacy . globalConfig$ ) ; } public start ( ) { } }