Skip to content

Commit c4d209c

Browse files
definitelynobodyafrad
authored andcommitted
Create readyStateConstants.UNINITIALIZED (#99)
This is more self documenting than returning -1.
1 parent f5ff844 commit c4d209c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/angular2-websocket.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class $WebSocket {
2929
private onErrorCallbacks = [];
3030
private onCloseCallbacks = [];
3131
private readyStateConstants = {
32+
'UNINITIALIZED': -1,
3233
'CONNECTING': 0,
3334
'OPEN': 1,
3435
'CLOSING': 2,
@@ -322,13 +323,9 @@ export class $WebSocket {
322323

323324
}
324325

325-
/**
326-
* Could be -1 if not initzialized yet
327-
* @returns {number}
328-
*/
329326
getReadyState() {
330327
if (this.socket == null) {
331-
return -1;
328+
return this.readyStateConstants.UNINITIALIZED;
332329
}
333330
return this.internalConnectionState || this.socket.readyState;
334331
}

0 commit comments

Comments
 (0)