8000 refactor(webSocket): rename back to webSocket ala 5.0 (#3590) · ReactiveX/rxjs@d5658fe · GitHub
[go: up one dir, main page]

Skip to content

Commit d5658fe

Browse files
authored
refactor(webSocket): rename back to webSocket ala 5.0 (#3590)
* refactor(webSocket): rename back to webSocket ala 5.0 BREAKING CHANGE: UNBREAKING websocket to be named `webSocket` again, just like it was in 5.0. Now you should import from `rxjs/webSocket` * refactor(webSocket): update tsconfig files * refactor(webSocket): update ./make-packages.js * refactor(webSocket): update webSocket for systemjs
1 parent f4d7d02 commit d5658fe

File tree

18 files changed

+60
-59
lines changed

18 files changed

+60
-59
lines changed

.make-packages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fs.copySync('./tsconfig.base.json', PKG_ROOT + 'src/tsconfig.json');
135135
fs.writeJsonSync(PKG_ROOT + 'package.json', rootPackageJson, {spaces: 2});
136136
fs.copySync('src/operators/package.json', PKG_ROOT + '/operators/package.json');
137137
fs.copySync('src/ajax/package.json', PKG_ROOT + '/ajax/package.json');
138-
fs.copySync('src/websocket/package.json', PKG_ROOT + '/websocket/package.json');
138+
fs.copySync('src/webSocket/package.json', PKG_ROOT + '/webSocket/package.json');
139139
fs.copySync('src/testing/package.json', PKG_ROOT + '/testing/package.json');
140140
fs.copySync('src/internal-compatibility/package.json', PKG_ROOT + '/internal-compatibility/package.json');
141141

MIGRATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Other export points:
3636

3737
- `rxjs/testing`: The `TestScheduler` and friends can be found here
3838
- `rxjs/ajax`: This is the new home for the rxjs AJAX implementation
39-
- `rxjs/websocket`: This is the home for the rxjs web socket implementation.
39+
- `rxjs/webSocket`: This is the home for the rxjs web socket implementation.
4040

4141

4242
### Import Migration Table

compat/add/observable/dom/webSocket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Observable } from 'rxjs';
2-
import { websocket as staticWebSocket } from 'rxjs/websocket';
2+
import { webSocket as staticWebSocket } from 'rxjs/webSocket';
33

44
Observable.webSocket = staticWebSocket;
55

integration/systemjs/systemjs-compatibility-spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ System.config({
88
'rxjs/ajax': {main: 'index.js', defaultExtension: 'js' },
99
'rxjs/operators': {main: 'index.js', defaultExtension: 'js' },
1010
'rxjs/testing': {main: 'index.js', defaultExtension: 'js' },
11-
'rxjs/websocket': {main: 'index.js', defaultExtension: 'js' }
11+
'rxjs/webSocket': {main: 'index.js', defaultExtension: 'js' }
1212
}
1313
});
1414

@@ -17,7 +17,7 @@ Promise.all([
1717
System.import('rxjs/ajax'),
1818
System.import('rxjs/operators'),
1919
System.import('rxjs/testing'),
20-
System.import('rxjs/websocket'),
20+
System.import('rxjs/webSocket'),
2121
]).then(
2222
function () { console.log('Successfully tested all entry-points with SystemJS!'); },
2323
function (error) {

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/observables/dom/webSocket-spec.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { expect } from 'chai';
22
import * as sinon from 'sinon';
3-
import { websocket } from 'rxjs/websocket';
3+
import { webSocket } from 'rxjs/webSocket';
44
import { map, retry, take, repeat, takeWhile } from 'rxjs/operators';
55

66
declare const __root__: any;
77

88
/** @test {webSocket} */
9-
describe('websocket', () => {
9+
describe('webSocket', () => {
1010
let __ws: any;
1111

1212
function setupMockWebSocket() {
@@ -30,7 +30,7 @@ describe('websocket', () => {
3030

3131
it('should send and receive messages', () => {
3232
let messageReceived = false;
33-
const subject = websocket<string>('ws://mysocket');
33+
const subject = webSocket<string>('ws://mysocket');
3434

3535
subject.next('ping');
3636

@@ -52,7 +52,7 @@ describe('websocket', () => {
5252
});
5353

5454
it('should allow use of operators and subscribe', () => {
55-
const subject = websocket<string>('ws://mysocket');
55+
const subject = webSocket<string>('ws://mysocket');
5656
const results: any[] = [];
5757

5858
subject.pipe(
@@ -68,7 +68,7 @@ describe('websocket', () => {
6868
it('receive multiple messages', () => {
6969
const expected = ['what', 'do', 'you', 'do', 'with', 'a', 'drunken', 'sailor?'];
7070
const results: string[] = [];
71-
const subject = websocket<string>('ws://mysocket');
71+
const subject = webSocket<string>('ws://mysocket');
7272

7373
subject.subscribe(x => {
7474
results.push(x);
@@ -89,7 +89,7 @@ describe('websocket', () => {
8989

9090
it('should queue messages prior to subscription', () => {
9191
const expected = ['make', 'him', 'walk', 'the', 'plank'];
92-
const subject = websocket<string>('ws://mysocket');
92+
const subject = webSocket<string>('ws://mysocket');
9393

9494
expected.forEach(x => {
9595
subject.next(x);
@@ -110,7 +110,7 @@ describe('websocket', () => {
110110
});
111111

112112
it('should send messages immediately if already open', () => {
113-
const subject = websocket<string>('ws://mysocket');
113+
const subject = webSocket<string>('ws://mysocket');
114114
subject.subscribe();
115115
const socket = MockWebSocket.lastSocket;
116116
socket.open();
@@ -124,7 +124,7 @@ describe('websocket', () => {
124124
});
125125

126126
it('should close the socket when completed', () => {
127-
const subject = websocket<string>('ws://mysocket');
127+
const subject = webSocket<string>('ws://mysocket');
128128
subject.subscribe();
129129
const socket = MockWebSocket.lastSocket;
130130
socket.open();
@@ -144,7 +144,7 @@ describe('websocket', () => {
144144
});
145145

146146
it('should close the socket with a code and a reason when errored', () => {
147-
const subject = websocket<string>('ws://mysocket');
147+
const subject = webSocket<string>('ws://mysocket');
148148
subject.subscribe();
149149
const socket = MockWebSocket.lastSocket;
150150
socket.open();
@@ -160,7 +160,7 @@ describe('websocket', () => {
160160
});
161161

162162
it('should allow resubscription after closure via complete', () => {
163-
const subject = websocket<string>('ws://mysocket');
163+
const subject = webSocket<string>('ws://mysocket');
164164
subject.subscribe();
165165
const socket1 = MockWebSocket.lastSocket;
166166
socket1.open();
@@ -178,7 +178,7 @@ describe('websocket', () => {
178178
});
179179

180180
it('should allow resubscription after closure via error', () => {
181-
const subject = websocket<string>('ws://mysocket');
181+
const subject = webSocket<string>('ws://mysocket');
182182
subject.subscribe();
183183
const socket1 = MockWebSocket.lastSocket;
184184
socket1.open();
@@ -198,7 +198,7 @@ describe('websocket', () => {
198198
it('should have a default resultSelector that parses message data as JSON', () => {
199199
let result;
200200
const expected = { mork: 'shazbot!' };
201-
const subject = websocket<string>('ws://mysocket');
201+
const subject = webSocket<string>('ws://mysocket');
202202

203203
subject.subscribe((x: any) => {
204204
result = x;
@@ -226,7 +226,7 @@ describe('websocket', () => {
226226

227227
it('should send and receive messages', () => {
228228
let messageReceived = false;
229-
const subject = websocket<string>({ url: 'ws://mysocket' });
229+
const subject = webSocket<string>({ url: 'ws://mysocket' });
230230

231231
subject.next('ping');
232232

@@ -248,7 +248,7 @@ describe('websocket', () => {
248248
});
249249

250250
it('should take a protocol and set it properly on the web socket', () => {
251-
const subject = websocket<string>({
251+
const subject = webSocket<string>({
252252
url: 'ws://mysocket',
253253
protocol: 'someprotocol'
254254
});
@@ -262,7 +262,7 @@ describe('websocket', () => {
262262
});
263263

264264
it('should take a binaryType and set it properly on the web socket', () => {
265-
const subject = websocket<string>({
265+
const subject = webSocket<string>({
266266
url: 'ws://mysocket',
267267
binaryType: 'blob'
268268
});
@@ -278,7 +278,7 @@ describe('websocket', () => {
278278
it('should take a deserializer', () => {
279279
const results = [] as string[];
280280

281-
const subject = websocket<string>({
281+
const subject = webSocket<string>({
282282
url: 'ws://mysocket',
283283
deserializer: (e: any) => {
284284
return e.data + '!';
@@ -301,7 +301,7 @@ describe('websocket', () => {
301301
});
302302

303303
it('if the deserializer fails it should go down the error path', () => {
304-
const subject = websocket<string>({
304+
const subject = webSocket<string>({
305305
url: 'ws://mysocket',
306306
deserializer: (e: any) => {
307307
throw new Error('I am a bad error');
@@ -323,7 +323,7 @@ describe('websocket', () => {
323323

324324
it('should accept a closingObserver', () => {
325325
let calls = 0;
326-
const subject = websocket<string>(<any>{
326+
const subject = webSocket<string>(<any>{
327327
url: 'ws://mysocket',
328328
closingObserver: {
329329
next(x: any) {
@@ -355,7 +355,7 @@ describe('websocket', () => {
355355
it('should accept a closeObserver', () => {
356356
const expected = [{ wasClean: true }, { wasClean: false }];
357357
const closes = [] as any[];
358-
const subject = websocket<string>(<any>{
358+
const subject = webSocket<string>(<any>{
359359
url: 'ws://mysocket',
360360
closeObserver: {
361361
next(e: any) {
@@ -390,7 +390,7 @@ describe('websocket', () => {
390390
});
391391

392392
it('should handle constructor errors', () => {
393-
const subject = websocket<string>(<any>{
393+
const subject = webSocket<string>(<any>{
394394
url: 'bad_url',
395395
WebSocketCtor: (url: string, protocol?: string | string[]): WebSocket => {
396396
throw new Error(`connection refused`);
@@ -419,7 +419,7 @@ describe('websocket', () => {
419419

420420
it('should be retryable', () => {
421421
const results = [] as string[];
422-
const subject = websocket<{ name: string, value: string }>('ws://websocket');
422+
const subject = webSocket<{ name: string, value: string }>('ws://websocket');
423423
const source = subject.multiplex(
424424
() => ({ sub: 'foo' }),
425425
() => ({ unsub: 'foo' }),
@@ -454,7 +454,7 @@ describe('websocket', () => {
454454

455455
it('should be repeatable', () => {
456456
const results = [] as string[];
457-
const subject = websocket<{ name: string, value: string }>('ws://websocket');
457+
const subject = webSocket<{ name: string, value: string }>('ws://websocket');
458458
const source = subject.multiplex(
459459
() => ({ sub: 'foo' }),
460460
() => ({ unsub: 'foo' }),
@@ -490,9 +490,9 @@ describe('websocket', () => {
490490
expect(results).to.deep.equal(['test', 'this', 'test',  10000 9;this'], 'results were not equal');
491491
});
492492

493-
it('should multiplex over the websocket', () => {
493+
it('should multiplex over the webSocket', () => {
494494
const results = [] as Array<{ value: number, name: string }>;
495-
const subject = websocket<{ value: number, name: string }>('ws://websocket');
495+
const subject = webSocket<{ value: number, name: string }>('ws://websocket');
496496
const source = subject.multiplex(
497497
() => ({ sub: 'foo'}),
498498
() => ({ unsub: 'foo' }),
@@ -527,7 +527,7 @@ describe('websocket', () => {
527527
});
528528

529529
it('should keep the same socket for multiple multiplex subscriptions', () => {
530-
const socketSubject = websocket<string>({url: 'ws://mysocket'});
530+
const socketSubject = webSocket<string>({url: 'ws://mysocket'});
531531
const results = [] as string[];
532532
const socketMessages = [
533533
{id: 'A'},
@@ -584,7 +584,7 @@ describe('websocket', () => {
584584
});
585585

586586
it('should not close the socket until all subscriptions complete', () => {
587-
const socketSubject = websocket<{ id: string, complete: boolean }>({url: 'ws://mysocket'});
587+
const socketSubject = webSocket<{ id: string, complete: boolean }>({url: 'ws://mysocket'});
588588
const results = [] as string[];
589589
const socketMessages = [
590590
{id: 'A'},

spec/websocket/index-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as index from 'rxjs/websocket';
1+
import * as index from 'rxjs/webSocket';
22
import { expect } from 'chai';
33

44
describe('index', () => {
55
it('should export static websocket subject creator functions', () => {
6-
expect(index.websocket).to.exist;
6+
expect(index.webSocket).to.exist;
77
});
88
});

src/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ ts_library(
3838
"//ajax",
3939
"//operators",
4040
"//testing",
41-
"//websocket",
41+
"//webSocket",
4242
],
4343
)

src/internal/observable/dom/WebSocketSubject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface WebSocketSubjectConfig<T> {
3030
*/
3131
openObserver?: NextObserver<Event>;
3232
/**
33-
* An Observer than watches when close events occur on the underlying websocket
33+
* An Observer than watches when close events occur on the underlying webSocket
3434
*/
3535
closeObserver?: NextObserver<CloseEvent>;
3636
/**

src/internal/observable/dom/webSocket.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { WebSocketSubject, WebSocketSubjectConfig } from './WebSocketSubject';
55
*
66
* @example <caption>Wraps browser WebSocket</caption>
77
*
8-
* import { webSocket } from 'rxjs/websocket';
8+
* import { webSocket } from 'rxjs/webSocket';
99
*
1010
* let socket$ = webSocket('ws://localhost:8081');
1111
*
@@ -17,14 +17,14 @@ import { WebSocketSubject, WebSocketSubjectConfig } from './WebSocketSubject';
1717
*
1818
* socket$.next(JSON.stringify({ op: 'hello' }));
1919
*
20-
* @example <caption>Wraps WebSocket from nodejs-websocket (using node.js)</caption>
20+
* @example <caption>Wraps WebSocket from nodejs-webSocket (using node.js)</caption>
2121
*
22-
* import { webSocket } from 'rxjs/websocket';
23-
* import { w3cwebsocket } from 'websocket';
22+
* import { webSocket } from 'rxjs/webSocket';
23+
* import { w3cwebSocket } from 'webSocket';
2424
*
2525
* let socket$ = webSocket({
2626
* url: 'ws://localhost:8081',
27-
* WebSocketCtor: w3cwebsocket
27+
* WebSocketCtor: w3cwebSocket
2828
* });
2929
*
3030
* socket$.subscribe(
@@ -35,7 +35,7 @@ import { WebSocketSubject, WebSocketSubjectConfig } from './WebSocketSubject';
3535
*
3636
* socket$.next(JSON.stringify({ op: 'hello' }));
3737
*
38-
* @param {string | WebSocketSubjectConfig} urlConfigOrSource the source of the websocket as an url or a structure defining the websocket object
38+
* @param {string | WebSocketSubjectConfig} urlConfigOrSource the source of the webSocket as an url or a structure defining the webSocket object
3939
* @return {WebSocketSubject}
4040
*/
4141
export function webSocket<T>(urlConfigOrSource: string | WebSocketSubjectConfig<T>): WebSocketSubject<T> {

0 commit comments

Comments
 (0)
0