|
2 | 2 |
|
3 | 3 | import * as appSettings from "application-settings";
|
4 | 4 | import * as AppVersion from "nativescript-appversion";
|
| 5 | +import * as application from "tns-core-modules/application"; |
5 | 6 | import { device } from "tns-core-modules/platform";
|
6 | 7 | import { confirm } from "tns-core-modules/ui/dialogs";
|
7 |
| -import * as application from "tns-core-modules/application"; |
8 | 8 | import { TNSAcquisitionManager } from "./TNSAcquisitionManager";
|
9 | 9 | import { TNSLocalPackage } from "./TNSLocalPackage";
|
10 | 10 | import { TNSRemotePackage } from "./TNSRemotePackage";
|
@@ -50,6 +50,11 @@ export enum SyncStatus {
|
50 | 50 | */
|
51 | 51 | ERROR = <any>"ERROR",
|
52 | 52 |
|
| 53 | + /** |
| 54 | + * Returned if HMR is enabled and not overridden by the user. |
| 55 | + */ |
| 56 | + SKIPPING_BECAUSE_HMR_ENABLED = <any>"SKIPPING_BECAUSE_HMR_ENABLED", |
| 57 | + |
53 | 58 | /**
|
54 | 59 | * There is an ongoing sync in progress, so this attempt to sync has been aborted.
|
55 | 60 | */
|
@@ -95,10 +100,12 @@ export class AppSync {
|
95 | 100 | throw new Error("Missing deploymentKey, pass it as part of the first parameter of the 'sync' function: { deploymentKey: 'your-key' }");
|
96 | 101 | }
|
97 | 102 |
|
98 |
| - if (AppSync.syncInProgress) { |
99 |
| - syncCallback && syncCallback(SyncStatus.IN_PROGRESS); |
| 103 | + // skip AppSync when HMR is detected, unless it's explicitly allowed |
| 104 | + if (typeof (<any>global).hmrRefresh === "function" && !options.enabledWhenUsingHmr) { |
| 105 | + syncCallback && syncCallback(SyncStatus.SKIPPING_BECAUSE_HMR_ENABLED); |
100 | 106 | return;
|
101 | 107 | }
|
| 108 | + |
102 | 109 | AppSync.syncInProgress = true;
|
103 | 110 |
|
104 | 111 | // by default, use our Cloud server
|
|
0 commit comments