Title: refactor(http): convert Connection interface to be Observable of Response · Issue #4472 · angular/angular · GitHub
Open Graph Title: refactor(http): convert Connection interface to be Observable of Response · Issue #4472 · angular/angular
X Title: refactor(http): convert Connection interface to be Observable of Response · Issue #4472 · angular/angular
Description: (recapping discussion with @Blesh, who will probably correct me) Current State Right now, the Connection interface, which is implemented by XHRConnection, JSONPConnection, and MockConnection, has simple interface: interface Connection { ...
Open Graph Description: (recapping discussion with @Blesh, who will probably correct me) Current State Right now, the Connection interface, which is implemented by XHRConnection, JSONPConnection, and MockConnection, has s...
X Description: (recapping discussion with @Blesh, who will probably correct me) Current State Right now, the Connection interface, which is implemented by XHRConnection, JSONPConnection, and MockConnection, has s...
Opengraph URL: https://github.com/angular/angular/issues/4472
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"refactor(http): convert Connection interface to be Observable of Response","articleBody":"(recapping discussion with @blesh, who will probably correct me)\n## Current State\n\nRight now, the [`Connection`](https://github.com/angular/angular/blob/a251df9df4a34592afb4984f7a3e13a186562234/modules/angular2/src/http/interfaces.ts#L22) interface, which is implemented by `XHRConnection`, `JSONPConnection`, and `MockConnection`, has simple interface:\n\n``` typescript\ninterface Connection {\n readyState: ReadyStates;\n request: Request;\n response: Observable\u003cResponse\u003e;\n}\n```\n\nCalls to the [Http](https://github.com/angular/angular/blob/a251df9df4a34592afb4984f7a3e13a186562234/modules/angular2/src/http/http.ts) service return the `connection.response` observable, so end users don't really interact with this interface too much in application code. In tests, however, users will be working with `MockConnection` instances created by [`MockBackend`](https://github.com/angular/angular/blob/a251df9df4a34592afb4984f7a3e13a186562234/modules/angular2/src/http/backends/mock_backend.ts) in order to create mock responses for requests.\n\n``` typescript\nmyService.getUsers().subscribe(users =\u003e {\n expect(users[0].name).toBe('Rob');\n async.done();\n});\nmockBackend.connections.subscribe(connection =\u003e {\n connection.mockRespond(mockUsers);\n});\n```\n\n(Note that the mock responding mechanism should be further improved, but that's outside the scope of this proposal).\n## Proposal\n\nChange `Connection` itself to be an Observable of `Response`, and keep `request` property intact. @blesh says it aint so bad to add properties to Observables (though adding methods is a bad idea because observable methods are expected to be operators).\n\n``` typescript\ninterface Connection extends Observable\u003cResponse\u003e { //Observable interface doesn't actually exist yet\n readyState: ReadyStates; // I would like to get rid of this property\n request: Request;\n}\n```\n\n`MockConnection` should extend subject, so that it can be `next`-ed with `Response`s.\n\n``` typescript\nclass MockConnection extends Subject\u003cResponse\u003e implements Connection {\n readyState: ReadyStates;\n request: Request;\n}\n```\n\nThis change is actually pretty minor from an end-user perspective, other than the change of calling `next` on the `MockConnection` rather than the current `mockRespond`. But internally, it reduces cruft and simplifies logic.\n\nCC: @robwormald \n","author":{"url":"https://github.com/jeffbcross","@type":"Person","name":"jeffbcross"},"datePublished":"2015-10-02T18:28:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/4472/angular/issues/4472"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e6d00278-f2a1-2ae5-5e9a-66eea0f119e8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B7AC:A0916:221B35:2DC2E4:6A615E67 |
| html-safe-nonce | 81c34ba431d5643b89178ac57e9b36b85092666ee521d66effecab53c2c9da48 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0FDOkEwOTE2OjIyMUIzNToyREMyRTQ6NkE2MTVFNjciLCJ2aXNpdG9yX2lkIjoiNTE1NTgxOTEzMzQ5OTE3MDQwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6f033274d1f5f6f8262bebd14627fbd55971473534f95c612c0555d8a5813a5e |
| hovercard-subject-tag | issue:109546106 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/4472/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afc1f5ed82aff8bfb8bc34d855cc0f2a067ca6b52627c5e3255f29c0828b396d/angular/angular/issues/4472 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afc1f5ed82aff8bfb8bc34d855cc0f2a067ca6b52627c5e3255f29c0828b396d/angular/angular/issues/4472 |
| og:image:alt | (recapping discussion with @Blesh, who will probably correct me) Current State Right now, the Connection interface, which is implemented by XHRConnection, JSONPConnection, and MockConnection, has s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jeffbcross |
| hostname | github.com |
| expected-hostname | github.com |
| None | c258d2b06b498220e3b94af28b26bbbf58f4203a6373725f779afcc867afd263 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5f67bc431418961e0814f1eb30a4231250e4726d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width