aboutsummaryrefslogtreecommitdiff
path: root/src/console/completion/hooks
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2022-05-08 13:33:46 +0000
committerGitHub <noreply@github.com>2022-05-08 13:33:46 +0000
commit9279fff1351406a1f6c37c074cc1997e6a9e97e3 (patch)
treecc8e53f783efc5eb737af31bb9dd15c9e6474782 /src/console/completion/hooks
parent4468afca7a8c9893f71f7e042b25f6c46ba49678 (diff)
parent2a6d6b0967c6f6e269c3eedf4bd6002aee26b9da (diff)
Merge pull request #1418 from ueokande/await-completions
Await fetching completions done completely
Diffstat (limited to 'src/console/completion/hooks')
-rw-r--r--src/console/completion/hooks/clients.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/console/completion/hooks/clients.ts b/src/console/completion/hooks/clients.ts
new file mode 100644
index 0000000..49deb0c
--- /dev/null
+++ b/src/console/completion/hooks/clients.ts
@@ -0,0 +1,23 @@
+import React from "react";
+import CompletionClient from "../../clients/CompletionClient";
+import CompletionType from "../../../shared/CompletionType";
+
+const completionClient = new CompletionClient();
+
+export const useGetCompletionTypes = (): [
+ CompletionType[] | undefined,
+ boolean
+] => {
+ type State = {
+ loading: boolean;
+ result?: CompletionType[];
+ };
+ const [state, setState] = React.useState<State>({ loading: true });
+
+ React.useEffect(() => {
+ completionClient.getCompletionTypes().then((result) => {
+ setState({ loading: false, result });
+ });
+ }, []);
+ return [state.result, state.loading];
+};