microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
fix-ts-error1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/services/remoteConfigHelper.ts

37lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { CancellationTokenSource } from "vscode";
5import { PromiseUtil } from "../../common/node/promise";
6import { Request } from "../../common/node/request";
7
8// eslint-disable-next-line @typescript-eslint/no-empty-interface
9export interface IConfig {}
10
11export async function downloadConfig<T extends IConfig | IConfig[]>(
12 endpointURL: string,
13): Promise<T> {
14 const resString = await Request.request(endpointURL, false, true);
15 return JSON.parse(resString);
16}
17
18export async function retryDownloadConfig<T extends IConfig | IConfig[]>(
19 endpointURL: string,
20 cancellationTokenSource: CancellationTokenSource,
21 retryCount = 60,
22): Promise<T> {
23 return PromiseUtil.retryAsync(
24 async () => {
25 try {
26 return await downloadConfig<T>(endpointURL);
27 } catch (err) {
28 return;
29 }
30 },
31 (config: any) => !!config,
32 retryCount,
33 2000,
34 `Could not download remote config from ${endpointURL}`,
35 cancellationTokenSource,
36 );
37}
38