File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,36 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
42
42
}
43
43
44
44
/**
45
- * @param urlConfigOrSource
45
+ * Wrapper around the w3c-compatible WebSocket object provided by the browser.
46
+ *
47
+ * @example <caption>Wraps browser WebSocket</caption>
48
+ *
49
+ * let subject = Observable.webSocket('ws://localhost:8081');
50
+ * subject.subscribe(
51
+ * (msg) => console.log('message received: ' + msg),
52
+ * (err) => console.log(err),
53
+ * () => console.log('complete')
54
+ * );
55
+ * subject.next(JSON.stringify({ op: 'hello' }));
56
+ *
57
+ * @example <caption>Wraps WebSocket from nodejs-websocket (using node.js)</caption>
58
+ *
59
+ * import { w3cwebsocket } from 'websocket';
60
+ *
61
+ * let socket = new WebSocketSubject({
62
+ * url: 'ws://localhost:8081',
63
+ * WebSocketCtor: w3cwebsocket
64
+ * });
65
+ *
66
+ * let subject = Observable.webSocket('ws://localhost:8081');
67
+ * subject.subscribe(
68
+ * (msg) => console.log('message received: ' + msg),
69
+ * (err) => console.log(err),
70
+ * () => console.log('complete')
71
+ * );
72
+ * subject.next(JSON.stringify({ op: 'hello' }));
73
+ *
74
+ * @param {string | WebSocketSubjectConfig } urlConfigOrSource the source of the websocket as an url or a structure defining the websocket object
46
75
* @return {WebSocketSubject }
47
76
* @static true
48
77
* @name webSocket
You can’t perform that action at this time.
0 commit comments