-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Console Monaco Migration] Add autocomplete polling to editor
- Loading branch information
1 parent
357b6f8
commit d23a7cb
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ins/console/public/application/containers/editor/monaco/use_setup_autocomplete_polling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { useEffect } from 'react'; | ||
import { AutocompleteInfo, Settings } from '../../../../services'; | ||
|
||
interface SetInitialValueParams { | ||
/** The Console autocomplete service. */ | ||
autocompleteInfo: AutocompleteInfo; | ||
/** The Console settings service. */ | ||
settingsService: Settings; | ||
} | ||
|
||
/** | ||
* Hook that sets up the autocomplete polling for Console editor. | ||
* | ||
* @param params The {@link SetInitialValueParams} to use. | ||
*/ | ||
export const useSetupAutocompletePolling = (params: SetInitialValueParams) => { | ||
const { autocompleteInfo, settingsService } = params; | ||
|
||
useEffect(() => { | ||
autocompleteInfo.retrieve(settingsService, settingsService.getAutocomplete()); | ||
|
||
return () => { | ||
autocompleteInfo.clearSubscriptions(); | ||
}; | ||
}, [autocompleteInfo, settingsService]); | ||
}; |