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

Commit 4afa86f

Browse files
author
Dimitar Kerezov
committed
Make cloud-device-emulator implement IDisposable
1 parent a46f51d commit 4afa86f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
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
*/

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)