Skip to content

Commit

Permalink
docs(webSocket): adds webSocket and WebSocketSubject documentation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy authored and benlesh committed Jan 29, 2017
1 parent 758aae9 commit cb21993
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/observable/dom/WebSocketSubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,36 @@ export class WebSocketSubject<T> extends AnonymousSubject<T> {
}

/**
* @param urlConfigOrSource
* Wrapper around the w3c-compatible WebSocket object provided by the browser.
*
* @example <caption>Wraps browser WebSocket</caption>
*
* let subject = Observable.webSocket('ws://localhost:8081');
* subject.subscribe(
* (msg) => console.log('message received: ' + msg),
* (err) => console.log(err),
* () => console.log('complete')
* );
* subject.next(JSON.stringify({ op: 'hello' }));
*
* @example <caption>Wraps WebSocket from nodejs-websocket (using node.js)</caption>
*
* import { w3cwebsocket } from 'websocket';
*
* let socket = new WebSocketSubject({
* url: 'ws://localhost:8081',
* WebSocketCtor: w3cwebsocket
* });
*
* let subject = Observable.webSocket('ws://localhost:8081');
* subject.subscribe(
* (msg) => console.log('message received: ' + msg),
* (err) => console.log(err),
* () => console.log('complete')
* );
* subject.next(JSON.stringify({ op: 'hello' }));
*
* @param {string | WebSocketSubjectConfig} urlConfigOrSource the source of the websocket as an url or a structure defining the websocket object
* @return {WebSocketSubject}
* @static true
* @name webSocket
Expand Down

0 comments on commit cb21993

Please sign in to comment.