docs(http): fix http documentation

Closes #3931
This commit is contained in:
Tamas Csaba 2015-09-01 09:55:37 +02:00 committed by Misko Hevery
parent 9b009b3159
commit e34a29dafe
4 changed files with 9 additions and 9 deletions

View File

@ -55,8 +55,8 @@ export class MockConnection implements Connection {
* *
* ``` * ```
* var connection; * var connection;
* backend.connections.subscribe(c => connection = c); * backend.connections.toRx().subscribe(c => connection = c);
* http.request('data.json').subscribe(res => console.log(res.text())); * http.request('data.json').toRx().subscribe(res => console.log(res.text()));
* connection.mockRespond(new Response('fake response')); //logs 'fake response' * connection.mockRespond(new Response('fake response')); //logs 'fake response'
* ``` * ```
* *
@ -117,8 +117,8 @@ export class MockConnection implements Connection {
* var http = injector.get(Http); * var http = injector.get(Http);
* var backend = injector.get(MockBackend); * var backend = injector.get(MockBackend);
* //Assign any newly-created connection to local variable * //Assign any newly-created connection to local variable
* backend.connections.subscribe(c => connection = c); * backend.connections.toRx().subscribe(c => connection = c);
* http.request('data.json').subscribe((res) => { * http.request('data.json').toRx().subscribe((res) => {
* expect(res.text()).toBe('awesome'); * expect(res.text()).toBe('awesome');
* async.done(); * async.done();
* }); * });
@ -151,8 +151,8 @@ export class MockBackend implements ConnectionBackend {
* }, [MockBackend, BaseRequestOptions]]); * }, [MockBackend, BaseRequestOptions]]);
* var backend = injector.get(MockBackend); * var backend = injector.get(MockBackend);
* var http = injector.get(Http); * var http = injector.get(Http);
* backend.connections.subscribe(c => connection = c); * backend.connections.toRx().subscribe(c => connection = c);
* http.request('something.json').subscribe(res => { * http.request('something.json').toRx().subscribe(res => {
* text = res.text(); * text = res.text();
* }); * });
* connection.mockRespond(new Response({body: 'Something'})); * connection.mockRespond(new Response({body: 'Something'}));

View File

@ -99,7 +99,7 @@ export class XHRConnection implements Connection {
* }) * })
* class MyComponent { * class MyComponent {
* constructor(http:Http) { * constructor(http:Http) {
* http('people.json').subscribe(res => this.people = res.json()); * http('people.json').toRx().subscribe(res => this.people = res.json());
* } * }
* } * }
* ``` * ```

View File

@ -83,7 +83,7 @@ export class RequestOptions {
* constructor(baseRequestOptions:BaseRequestOptions, http:Http) { * constructor(baseRequestOptions:BaseRequestOptions, http:Http) {
* var options = baseRequestOptions.merge({body: 'foobar', url: 'https://foo'}); * var options = baseRequestOptions.merge({body: 'foobar', url: 'https://foo'});
* var request = new Request(options); * var request = new Request(options);
* http.request(request).subscribe(res => this.bars = res.json()); * http.request(request).toRx().subscribe(res => this.bars = res.json());
* } * }
* } * }
* *

View File

@ -15,7 +15,7 @@ import {isJsObject} from './http_utils';
* #Example * #Example
* *
* ``` * ```
* http.request('my-friends.txt').subscribe(response => this.friends = response.text()); * http.request('my-friends.txt').toRx().subscribe(response => this.friends = response.text());
* ``` * ```
* *
* The Response's interface is inspired by the Response constructor defined in the [Fetch * The Response's interface is inspired by the Response constructor defined in the [Fetch