microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.9.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/abstractDeviceTracker.ts

33lines · modeblame

4bb0956eRedMickey5 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { OutputChannelLogger } from "./log/OutputChannelLogger";
5
6export abstract class AbstractDeviceTracker {
7protected logger: OutputChannelLogger;
8protected isStop: boolean;
9
10constructor() {
11this.logger = OutputChannelLogger.getMainChannel();
12this.isStop = false;
13}
14
15public abstract start(): Promise<void>;
16
17public abstract stop(): void;
18
19protected async queryDevicesLoop(): Promise<void> {
20try {
21await this.queryDevices();
22if (!this.isStop) {
23// It's important to schedule the next check AFTER the current one has completed
24// to avoid simultaneous queries which can cause multiple user input prompts.
25setTimeout(() => this.queryDevicesLoop(), 3000);
26}
27} catch (err) {
28this.logger.error(err.toString());
29}
30}
31
32protected abstract queryDevices(): Promise<void>;
33}