Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 04f36c1

Browse files
Merge pull request #26 from NativeScript/kerezov/dispose
Make cloud-device-emulator implement IDisposable
2 parents a63d238 + c0a9d48 commit 04f36c1

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

lib/cloud-device-emulator.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ export class CloudDeviceEmulatorWrapper implements ICloudDeviceEmulator {
55
return this.cloudDeviceEmulatorInstance.deviceEmitter;
66
}
77

8-
constructor() {
8+
constructor(private $options: IOptions,
9+
private $processService: IProcessService) {
910
this.cloudDeviceEmulatorInstance = require("cloud-device-emulator");
11+
this.$processService.attachToProcessExitSignals(this, this._dispose);
1012
}
1113

1214
public getSeverAddress(): Promise<ICloudDeviceServerInfo> {
@@ -20,6 +22,16 @@ export class CloudDeviceEmulatorWrapper implements ICloudDeviceEmulator {
2022
public killServer(): Promise<any> {
2123
return this.cloudDeviceEmulatorInstance.killServer();
2224
}
25+
26+
public dispose() {
27+
if (!this.$options.watch) {
28+
this._dispose();
29+
}
30+
}
31+
32+
private _dispose() {
33+
this.cloudDeviceEmulatorInstance.deviceEmitter.dispose();
34+
}
2335
}
2436

2537
$injector.register("cloudDeviceEmulator", CloudDeviceEmulatorWrapper);

lib/definitions/emulators.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface IAppetizeEmulatorLauncher {
3232
/**
3333
* Describes service for interaction with server which communicates with cloud emulators.
3434
*/
35-
interface ICloudDeviceEmulator {
35+
interface ICloudDeviceEmulator extends IDisposable {
3636
/**
3737
* Event emitter instance that raises events upon finding/losing a device.
3838
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"typescript": "2.1.5"
4646
},
4747
"dependencies": {
48-
"cloud-device-emulator": "~0.2.0",
48+
"cloud-device-emulator": "0.3.0",
4949
"cookie": "0.3.1",
5050
"lodash": "4.17.4",
5151
"minimatch": "3.0.4",

test/mobile/mobile-core/appetize-device-discovery.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CustomDeviceEmitter extends EventEmitter implements CloudDeviceEmitter {
1414
public getCurrentlyAttachedDevices(): IAttachedDevices {
1515
return this._initialDevices;
1616
}
17+
public dispose(): void { /* empty */ }
1718
}
1819

1920
describe("appetize device discovery", () => {

0 commit comments

Comments
 (0)