@@ -3,18 +3,29 @@ import * as util from "util";
33import { APP_FOLDER_NAME } from "../../constants" ;
44
55export abstract class PlatformLiveSyncServiceBase {
6+ private _deviceLiveSyncServicesCache : IDictionary < INativeScriptDeviceLiveSyncService > = { } ;
7+
68 constructor ( protected $fs : IFileSystem ,
79 protected $logger : ILogger ,
810 protected $platformsData : IPlatformsData ,
911 protected $projectFilesManager : IProjectFilesManager ,
1012 private $devicePathProvider : IDevicePathProvider ,
1113 private $projectFilesProvider : IProjectFilesProvider ) { }
1214
13- public abstract getDeviceLiveSyncService ( device : Mobile . IDevice ) : INativeScriptDeviceLiveSyncService ;
15+ public getDeviceLiveSyncService ( device : Mobile . IDevice , applicationIdentifier : string ) : INativeScriptDeviceLiveSyncService {
16+ const key = device . deviceInfo . identifier + applicationIdentifier ;
17+ if ( ! this . _deviceLiveSyncServicesCache [ key ] ) {
18+ this . _deviceLiveSyncServicesCache [ key ] = this . _getDeviceLiveSyncService ( device ) ;
19+ }
20+
21+ return this . _deviceLiveSyncServicesCache [ key ] ;
22+ }
23+
24+ protected abstract _getDeviceLiveSyncService ( device : Mobile . IDevice ) : INativeScriptDeviceLiveSyncService ;
1425
1526 public async refreshApplication ( projectData : IProjectData , liveSyncInfo : ILiveSyncResultInfo ) : Promise < void > {
1627 if ( liveSyncInfo . isFullSync || liveSyncInfo . modifiedFilesData . length ) {
17- const deviceLiveSyncService = this . getDeviceLiveSyncService ( liveSyncInfo . deviceAppData . device ) ;
28+ const deviceLiveSyncService = this . getDeviceLiveSyncService ( liveSyncInfo . deviceAppData . device , projectData . projectId ) ;
1829 this . $logger . info ( "Refreshing application..." ) ;
1930 await deviceLiveSyncService . refreshApplication ( projectData , liveSyncInfo ) ;
2031 }
@@ -23,7 +34,7 @@ export abstract class PlatformLiveSyncServiceBase {
2334 public async fullSync ( syncInfo : IFullSyncInfo ) : Promise < ILiveSyncResultInfo > {
2435 const projectData = syncInfo . projectData ;
2536 const device = syncInfo . device ;
26- const deviceLiveSyncService = this . getDeviceLiveSyncService ( device ) ;
37+ const deviceLiveSyncService = this . getDeviceLiveSyncService ( device , syncInfo . projectData . projectId ) ;
2738 const platformData = this . $platformsData . getPlatformData ( device . deviceInfo . platform , projectData ) ;
2839 const deviceAppData = await this . getAppData ( syncInfo ) ;
2940
@@ -79,7 +90,7 @@ export abstract class PlatformLiveSyncServiceBase {
7990 const localToDevicePaths = await this . $projectFilesManager . createLocalToDevicePaths ( deviceAppData , projectFilesPath , mappedFiles , [ ] ) ;
8091 modifiedLocalToDevicePaths . push ( ...localToDevicePaths ) ;
8192
82- const deviceLiveSyncService = this . getDeviceLiveSyncService ( device ) ;
93+ const deviceLiveSyncService = this . getDeviceLiveSyncService ( device , projectData . projectId ) ;
8394 deviceLiveSyncService . removeFiles ( deviceAppData , localToDevicePaths ) ;
8495 }
8596
0 commit comments