@@ -21,6 +21,7 @@ const LiveSyncEvents = {
21
21
export class LiveSyncService extends EventEmitter implements IDebugLiveSyncService {
22
22
// key is projectDir
23
23
protected liveSyncProcessesInfo : IDictionary < ILiveSyncProcessInfo > = { } ;
24
+ private platformLiveSyncServices : IDictionary < IPlatformLiveSyncService > = { } ;
24
25
25
26
constructor ( private $platformService : IPlatformService ,
26
27
private $projectDataService : IProjectDataService ,
@@ -347,6 +348,15 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
347
348
}
348
349
349
350
private getLiveSyncService ( platform : string ) : IPlatformLiveSyncService {
351
+ const normalizedPlatformName = this . $mobileHelper . normalizePlatformName ( platform ) ;
352
+ if ( ! this . platformLiveSyncServices [ normalizedPlatformName ] ) {
353
+ this . platformLiveSyncServices [ normalizedPlatformName ] = this . getLiveSyncServiceCore ( platform ) ;
354
+ }
355
+
356
+ return this . platformLiveSyncServices [ normalizedPlatformName ] ;
357
+ }
358
+
359
+ private getLiveSyncServiceCore ( platform : string ) : IPlatformLiveSyncService {
350
360
if ( this . $mobileHelper . isiOSPlatform ( platform ) ) {
351
361
return this . $injector . resolve ( "iOSLiveSyncService" ) ;
352
362
} else if ( this . $mobileHelper . isAndroidPlatform ( platform ) ) {
@@ -456,8 +466,11 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
456
466
const deviceAction = async ( device : Mobile . IDevice ) : Promise < void > => {
457
467
try {
458
468
const platform = device . deviceInfo . platform ;
469
+ const liveSyncService = this . getLiveSyncService ( platform ) ;
459
470
const deviceBuildInfoDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
460
471
472
+ liveSyncService . prepareForLiveSync ( device , projectData , liveSyncData ) ;
473
+
461
474
await this . ensureLatestAppPackageIsInstalledOnDevice ( {
462
475
device,
463
476
preparedPlatforms,
@@ -472,7 +485,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
472
485
env : liveSyncData . env
473
486
} , { skipNativePrepare : deviceBuildInfoDescriptor . skipNativePrepare } ) ;
474
487
475
- const liveSyncResultInfo = await this . getLiveSyncService ( platform ) . fullSync ( {
488
+ const liveSyncResultInfo = await liveSyncService . fullSync ( {
476
489
projectData, device,
477
490
syncAllFiles : liveSyncData . watchAllFiles ,
478
491
useLiveEdit : liveSyncData . useLiveEdit ,
0 commit comments