Skip to content

Commit 60ac2e5

Browse files
authored
Merge pull request #61 from nickpisacane/minor-fixes
Fix start() if running, and start() and kill() when keepAlive is true.
2 parents b5414a1 + 22c3799 commit 60ac2e5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,19 @@ class StaticServer {
5454

5555
this.started = false;
5656
this._origin = undefined;
57+
this._handleAppStateChangeFn = this._handleAppStateChange.bind(this);
5758
}
5859

5960
start() {
6061
if( this.running ){
61-
return new Promise((resolve, reject) => {
62-
resolve(this.origin);
63-
});
62+
return Promise.resolve(this.origin);
6463
}
6564

6665
this.started = true;
6766
this.running = true;
6867

6968
if (!this.keepAlive && (Platform.OS === 'android')) {
70-
AppState.addEventListener('change', this._handleAppStateChange.bind(this));
69+
AppState.addEventListener('change', this._handleAppStateChangeFn);
7170
}
7271

7372
return FPStaticServer.start(this.port, this.root, this.localOnly, this.keepAlive)
@@ -87,7 +86,7 @@ class StaticServer {
8786
this.stop();
8887
this.started = false;
8988
this._origin = undefined;
90-
AppState.removeEventListener('change', this._handleAppStateChange.bind(this));
89+
AppState.removeEventListener('change', this._handleAppStateChangeFn);
9190
}
9291

9392
_handleAppStateChange(appState) {

0 commit comments

Comments
 (0)