Skip to content

Commit e758cba

Browse files
guiohmafrad
authored andcommitted
Angular6/RxJs6 upgrade (#106)
1 parent 1da132c commit e758cba

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

angular2-websocket.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Observable } from 'rxjs/Observable';
2-
import { Subject } from 'rxjs/Subject';
1+
import { Observable, Subject } from 'rxjs';
32
export declare class $WebSocket {
43
private url;
54
private protocols;

package.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "angular2-websocket",
33
"main": "angular2-websocket",
44
"version": "0.9.6",
5-
"license": "MIT",
5+
"license": "MIT",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"compile": "tsc",
@@ -18,30 +18,26 @@
1818
"bluebird": "^3.4.6"
1919
},
2020
"peerDependencies": {
21-
"@angular/common": "^4.4.6",
22-
"@angular/compiler": "^4.4.6",
23-
"@angular/core": "^4.4.6",
2421
"core-js": "^2.4.1",
2522
"reflect-metadata": "^0.1.8",
26-
"rxjs": "^5.4.0",
2723
"typescript": "^2.4.0",
2824
"zone.js": "^0.8.12"
2925
},
3026
"devDependencies": {
31-
"@angular/common": "^4.4.6",
32-
"@angular/compiler": "^4.4.6",
33-
"@angular/core": "4.4.6",
34-
"codelyzer": "~3.2.0",
27+
"@angular/common": "^6.0.2",
28+
"@angular/compiler": "^6.0.2",
29+
"@angular/core": "6.0.2",
30+
"@types/bluebird": "^3.0.35",
31+
"codelyzer": "^4.3.0",
3532
"core-js": "^2.4.1",
3633
"grunt": "~0.4.1",
3734
"grunt-contrib-uglify": "~0.2.4",
3835
"grunt-typescript": "~0.2.4",
3936
"reflect-metadata": "^0.1.8",
40-
"rxjs": "^5.4.0",
37+
"rxjs": "^6.1.0",
4138
"tslint": "~5.7.0",
4239
"typescript": "^2.4.0",
4340
"typings": "^2.0.0",
44-
"@types/bluebird": "^3.0.35",
4541
"zone.js": "^0.8.12"
4642
}
4743
}

src/angular2-websocket.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Injectable} from '@angular/core';
2-
import {Observable} from 'rxjs/Observable';
3-
import {Subject} from 'rxjs/Subject';
2+
import {Observable, Subject} from 'rxjs';
43

54
export class $WebSocket {
65

@@ -43,17 +42,17 @@ export class $WebSocket {
4342
private errorMessages: Subject<any>;
4443
private internalConnectionState: number;
4544

46-
constructor(private url: string,
47-
private protocols?: Array<string>,
48-
private config?: WebSocketConfig,
49-
private binaryType?: BinaryType)
45+
constructor(private url: string,
46+
private protocols?: Array<string>,
47+
private config?: WebSocketConfig,
48+
private binaryType?: BinaryType)
5049
{
5150
let match = new RegExp('wss?:\/\/').test(url);
5251
if (!match) {
5352
throw new Error('Invalid url provided');
5453
}
5554
this.config = Object.assign({ initialTimeout: 500, maxTimeout: 300000, reconnectIfNotNormalClose: false }, config);
56-
this.binaryType = binaryType || "blob";
55+
this.binaryType = binaryType || 'blob';
5756
this.dataStream = new Subject();
5857
this.errorMessages = new Subject();
5958
this.connect(true);
@@ -64,7 +63,7 @@ export class $WebSocket {
6463
let self = this;
6564
if (force || !this.socket || this.socket.readyState !== this.readyStateConstants.OPEN) {
6665
self.socket = this.protocols ? new WebSocket(this.url, this.protocols) : new WebSocket(this.url);
67-
self.socket.binaryType = self.binaryType.toString();
66+
self.socket.binaryType = self.binaryType;
6867

6968
self.socket.onopen = (ev: Event) => {
7069
// console.log('onOpen: ', ev);
@@ -169,15 +168,15 @@ export class $WebSocket {
169168
* @returns {any}
170169
*/
171170
send(data: any, mode?: WebSocketSendMode, binary?: boolean): any {
172-
switch (typeof mode !== "undefined" ? mode : this.send4Mode) {
171+
switch (typeof mode !== 'undefined' ? mode : this.send4Mode) {
173172
case WebSocketSendMode.Direct:
174173
return this.send4Direct(data, binary);
175174
case WebSocketSendMode.Promise:
176175
return this.send4Promise(data, binary);
177176
case WebSocketSendMode.Observable:
178177
return this.send4Observable(data, binary);
179178
default:
180-
throw Error("WebSocketSendMode Error.");
179+
throw Error('WebSocketSendMode Error.');
181180
}
182181
}
183182

0 commit comments

Comments
 (0)