{"action":"created","issue":{"url":"https://api.github.com/repos/teambition/teambition-sdk/issues/309","repository_url":"https://api.github.com/repos/teambition/teambition-sdk","labels_url":"https://api.github.com/repos/teambition/teambition-sdk/issues/309/labels{/name}","comments_url":"https://api.github.com/repos/teambition/teambition-sdk/issues/309/comments","events_url":"https://api.github.com/repos/teambition/teambition-sdk/issues/309/events","html_url":"https://github.com/teambition/teambition-sdk/pull/309","id":243581642,"number":309,"title":"令 SDKFetch 上的 get/put/post/delete 方法默认返回 Observable","user":{"login":"chuan6","id":963011,"avatar_url":"https://avatars1.githubusercontent.com/u/963011?v=4","gravatar_id":"","url":"https://api.github.com/users/chuan6","html_url":"https://github.com/chuan6","followers_url":"https://api.github.com/users/chuan6/followers","following_url":"https://api.github.com/users/chuan6/following{/other_user}","gists_url":"https://api.github.com/users/chuan6/gists{/gist_id}","starred_url":"https://api.github.com/users/chuan6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuan6/subscriptions","organizations_url":"https://api.github.com/users/chuan6/orgs","repos_url":"https://api.github.com/users/chuan6/repos","events_url":"https://api.github.com/users/chuan6/events{/privacy}","received_events_url":"https://api.github.com/users/chuan6/received_events","type":"User","site_admin":false},"labels":[{"id":418767647,"url":"https://api.github.com/repos/teambition/teambition-sdk/labels/REFACTOR","name":"REFACTOR","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":{"login":"chuan6","id":963011,"avatar_url":"https://avatars1.githubusercontent.com/u/963011?v=4","gravatar_id":"","url":"https://api.github.com/users/chuan6","html_url":"https://github.com/chuan6","followers_url":"https://api.github.com/users/chuan6/followers","following_url":"https://api.github.com/users/chuan6/following{/other_user}","gists_url":"https://api.github.com/users/chuan6/gists{/gist_id}","starred_url":"https://api.github.com/users/chuan6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuan6/subscriptions","organizations_url":"https://api.github.com/users/chuan6/orgs","repos_url":"https://api.github.com/users/chuan6/repos","events_url":"https://api.github.com/users/chuan6/events{/privacy}","received_events_url":"https://api.github.com/users/chuan6/received_events","type":"User","site_admin":false},"assignees":[{"login":"chuan6","id":963011,"avatar_url":"https://avatars1.githubusercontent.com/u/963011?v=4","gravatar_id":"","url":"https://api.github.com/users/chuan6","html_url":"https://github.com/chuan6","followers_url":"https://api.github.com/users/chuan6/followers","following_url":"https://api.github.com/users/chuan6/following{/other_user}","gists_url":"https://api.github.com/users/chuan6/gists{/gist_id}","starred_url":"https://api.github.com/users/chuan6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuan6/subscriptions","organizations_url":"https://api.github.com/users/chuan6/orgs","repos_url":"https://api.github.com/users/chuan6/repos","events_url":"https://api.github.com/users/chuan6/events{/privacy}","received_events_url":"https://api.github.com/users/chuan6/received_events","type":"User","site_admin":false}],"milestone":null,"comments":17,"created_at":"2017-07-18T02:27:25Z","updated_at":"2017-08-01T03:51:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/teambition/teambition-sdk/pulls/309","html_url":"https://github.com/teambition/teambition-sdk/pull/309","diff_url":"https://github.com/teambition/teambition-sdk/pull/309.diff","patch_url":"https://github.com/teambition/teambition-sdk/pull/309.patch"},"body":"...而不是 Http 对象。\r\n\r\n- [x] 将 X-Request-Id 移出 Net/Net\r\n- [x] 将 X-Request-Id 移出 Net/Http\r\n- [x] 修改 SDKFetch 上 get/put/post/delete 接口\r\n- [x] 在匹配项目中创建使用新接口的分支\r\n\r\n为 SDKFetch HTTP 方法接口提供 options 参数，如下：\r\n\r\n```typescript\r\nexport interface SDKFetchOptions {\r\n  includeHeaders?: boolean,  // 结果是否包含 response headers\r\n  returnHttpObject?: boolean // 返回 Http 对象还是返回 Observable\r\n}\r\n```\r\n\r\n在 SDKFetch 的 HTTP 方法接口上，做了如下修改：\r\n\r\n> 每个方法在原有参数列表之后添加一个 options 参数，默认值为 `{}`。即：默认不需要 response headers，且直接返回 Observable。\r\n>\r\n> 当且仅当传入 options 参数里有 `returnHttpObject` 字段的值为真，返回 Http 对象，其余情况均返回 Observable。\r\n\r\n在 Http 的接口上，保留原有设计，调用 `get/put/post/delete` 之后需要通过再调用 `send` 获得 Observable<_response_>。仅做的修改如下：\r\n\r\n> 在 Http 构造函数的原参数列表上添加了一个 `includeHeaders` 参数，默认值为 `false`。即：默认不需要 response headers。\r\n\r\n在使用到接口的地方，有这样几个改变（或者说回溯到引入 Http 之前的使用方法）：\r\n\r\n> 直接调用 SDKFetch 对象上的 `get/put/post/delete` 方法时，不再需要调用 `send()`。\r\n>\r\n> 调用 SDKFetch 对象上的各种 fetch api 接口时，也不再需要调用 `send()`。\r\n>\r\n> 在构造 `Net.prototype.lift` 上的 `request` 字段参数时，传入 Observable。如果源 Observable 需要转换，可以直接在 Observable 上写 map。\r\n\r\n即：在使用者这里，日常情况下不再需要直接接触 Http 对象，而是回归到使用更稳定、更易操作的 Observable<_response_>。\r\n\r\n**注：**\r\n\r\n之所以引入 `includeHeaders` 这个与本 issue 不是直接相关的 flag，是为了保留对 X-Request-Id 这个自定义 headers field 的使用（虽然其实目前并没有地方在使用这个功能）。\r\n\r\n...resolves #281 "},"comment":{"url":"https://api.github.com/repos/teambition/teambition-sdk/issues/comments/319260290","html_url":"https://github.com/teambition/teambition-sdk/pull/309#issuecomment-319260290","issue_url":"https://api.github.com/repos/teambition/teambition-sdk/issues/309","id":319260290,"user":{"login":"coveralls","id":2354108,"avatar_url":"https://avatars1.githubusercontent.com/u/2354108?v=4","gravatar_id":"","url":"https://api.github.com/users/coveralls","html_url":"https://github.com/coveralls","followers_url":"https://api.github.com/users/coveralls/followers","following_url":"https://api.github.com/users/coveralls/following{/other_user}","gists_url":"https://api.github.com/users/coveralls/gists{/gist_id}","starred_url":"https://api.github.com/users/coveralls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveralls/subscriptions","organizations_url":"https://api.github.com/users/coveralls/orgs","repos_url":"https://api.github.com/users/coveralls/repos","events_url":"https://api.github.com/users/coveralls/events{/privacy}","received_events_url":"https://api.github.com/users/coveralls/received_events","type":"User","site_admin":false},"created_at":"2017-08-01T03:51:25Z","updated_at":"2017-08-01T03:51:25Z","body":"\n[![Coverage Status](https://coveralls.io/builds/12633690/badge)](https://coveralls.io/builds/12633690)\n\nCoverage increased (+0.2%) to 96.418% when pulling **0e575a809ce6a2e160e7fde8b25a190e72e5909f on http-remove-send** into **c1899083ab8e5c9b49068857f6ed38a3befb9686 on release**.\n"}}
{"actor":{"display_login":"coveralls"}}