Skip to content

Commit 5662be4

Browse files
committed
Tidied up some code
1 parent 940f171 commit 5662be4

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/socket-daemon.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ const LOOPBACK_ADDRESS = '127.0.0.1';
5353
const LOOPBACK_HOSTNAME = 'localhost';
5454
const LOOKUP_PORT_START = 8991;
5555
const LOOKUP_PORT_END = 9000;
56-
5756
const POLLING_INTERVAL = 1000;
58-
5957
const CANT_FIND_AGENT_MESSAGE = 'Arduino Create Agent cannot be found';
6058
let updateAttempts = 0;
61-
6259
let orderedPluginAddresses = [LOOPBACK_ADDRESS, LOOPBACK_HOSTNAME];
6360

6461
if (browser.name !== 'chrome' && browser.name !== 'firefox') {
@@ -107,7 +104,7 @@ export default class SocketDaemon {
107104
this._tryPorts(orderedPluginAddresses[0])
108105
.catch(() => this._tryPorts(orderedPluginAddresses[1]))
109106
.then(() => this.agentFound.next(true))
110-
.catch(() => timer(POLLING_INTERVAL).subscribe(() => this.findAgent()));
107+
.catch(() => timer(POLLING_INTERVAL).subscribe(this.findAgent.bind(this)));
111108
}
112109

113110
/**
@@ -153,7 +150,7 @@ export default class SocketDaemon {
153150
return this.update();
154151
}
155152
if (updateAttempts < 10) {
156-
return setTimeout(() => this.update(), 10000);
153+
return timer(10000).subscribe(this.update().bind(this));
157154
}
158155
}
159156
return Promise.reject(new Error(`${CANT_FIND_AGENT_MESSAGE} at ${hostname}`));

0 commit comments

Comments
 (0)