I am creating an intranet web application using the Angular framework with Typescript.
The application needs to work with the client's machine so I have implemented some COM functionality called using ActiveX technology (we use Internet Explorer so it works fine).
I have 2 functions:
openApp - which copies a file from the server to the local machine
getInstalledVersion - reads version information from the local coy of the file
What I would like to do is after openApp is called I would like to call getInstalledVersion (to get the version info for the newly copied file). Obviously I want to ensure the copy process is complete before I call getInstalledVersion.
This sounds like a case for either wrapping openApp in a Promise, or finding some other way to call getInstalledVersion only once openApp has completed.
Could somebody point me in a direction for how I might achieve this?
Existing code below:
export class AppService implements IAppService {
private _appServiceClass: any;
constructor() {
this._appServiceClass = new ActiveXObject("BeaufortAppStoreClientProcessing.Services.AppServiceJsonWrapper");
}
openApp(app: IApp, sourceRootFolder: string, destinationRootFolder: string): void {
var jsonApp = JSON.stringify(app);
this._appServiceClass.OpenApp(jsonApp, app.AppType.AppTypeID, sourceRootFolder, destinationRootFolder);
// Want to call getInstalledVersion here after openApp succeeds.
}
getInstalledVersion(app: IApp): string {
var version: string;
var appType = app.AppType.AppTypeID;
switch (appType) {
case 1:
var jsonApp = JSON.stringify(app);
version = this._appServiceClass.GetInstalledVersion(jsonApp).toString();
break;
case 2:
version = "n/a";
break;
default:
version = "Incorrect AppType";
break;
}
return version;
}
}