{"action":"created","comment":{"url":"https://api.github.com/repos/square/retrofit/pulls/comments/28565892","id":28565892,"diff_hunk":"@@ -21,24 +24,35 @@\n   RxSupport() {\n   }\n \n-  Observable createRequestObservable(final Invoker invoker) {\n-    return Observable.create(new Observable.OnSubscribe<Object>() {\n-      @Override public void call(final Subscriber<? super Object> subscriber) {\n-        invoker.invoke(new Invoker.Callback() {\n-          @Override public void next(Object o) {\n-            if (!subscriber.isUnsubscribed()) {\n-              subscriber.onNext(o);\n-              subscriber.onCompleted();\n-            }\n-          }\n+  Observable createRequestObservable(final Invoker invoker, final RequestBuilder requestBuilder,\n+      final RequestInterceptor requestInterceptor) {\n+    return Observable.defer(new Func0<Observable<Object>>() {","path":"retrofit/src/main/java/retrofit/RxSupport.java","position":36,"original_position":36,"commit_id":"cdbf6dff20e4fbffd008800b15df6d4d7f066216","original_commit_id":"cdbf6dff20e4fbffd008800b15df6d4d7f066216","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"body":"In general, we try very-hard to minimize the per-request allocations and RxJava is extremely liberal in its allocations. Avoiding it as much as possible (which is ironic) is usually a good practice.\r\n\r\nYour larger example exercises OkHttp's synchronous API which we can't use. All interactions will be async such that the threading model is pushed down into OkHttp which allows for optimizations in both controlling per-server connections as well as more effective interleaving with HTTP/2.\r\n\r\nIn general this code will churn a lot in the next 6 weeks, so I'm inclined to just defer (ha!) changing it.","created_at":"2015-04-17T02:16:46Z","updated_at":"2015-04-17T02:16:46Z","html_url":"https://github.com/square/retrofit/pull/796#discussion_r28565892","pull_request_url":"https://api.github.com/repos/square/retrofit/pulls/796","_links":{"self":{"href":"https://api.github.com/repos/square/retrofit/pulls/comments/28565892"},"html":{"href":"https://github.com/square/retrofit/pull/796#discussion_r28565892"},"pull_request":{"href":"https://api.github.com/repos/square/retrofit/pulls/796"}}},"pull_request":{"url":"https://api.github.com/repos/square/retrofit/pulls/796","id":32125070,"html_url":"https://github.com/square/retrofit/pull/796","diff_url":"https://github.com/square/retrofit/pull/796.diff","patch_url":"https://github.com/square/retrofit/pull/796.patch","issue_url":"https://api.github.com/repos/square/retrofit/issues/796","number":796,"state":"open","locked":false,"title":"Makes Rx Observable creation defer request interception until Observable subscription","user":{"login":"jnlopar","id":1297988,"avatar_url":"https://avatars.githubusercontent.com/u/1297988?v=3","gravatar_id":"","url":"https://api.github.com/users/jnlopar","html_url":"https://github.com/jnlopar","followers_url":"https://api.github.com/users/jnlopar/followers","following_url":"https://api.github.com/users/jnlopar/following{/other_user}","gists_url":"https://api.github.com/users/jnlopar/gists{/gist_id}","starred_url":"https://api.github.com/users/jnlopar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnlopar/subscriptions","organizations_url":"https://api.github.com/users/jnlopar/orgs","repos_url":"https://api.github.com/users/jnlopar/repos","events_url":"https://api.github.com/users/jnlopar/events{/privacy}","received_events_url":"https://api.github.com/users/jnlopar/received_events","type":"User","site_admin":false},"body":"Makes Rx Observable creation defer request interception until Observable subscription, allowing it to be run on a background scheduler defined via subscribeOn on the returned Observable. No scheduler is applied by default.\r\n\r\nAdds test case for defer, and refactors the other Rx test methods to use TestSubscriber, which seems a bit easier to read and maintain than custom concurrency management w/CountdownLatch.\r\n\r\nThis helps manage cases such as getting a blocking Oauth token. OkHttp's interceptors are a good alternative if using OkHttp, but this provides an option for Rx users directly via retrofit.","created_at":"2015-03-27T16:55:28Z","updated_at":"2015-04-17T02:16:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"021082538133963c1c7e7c1706b7472d7a480823","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/retrofit/pulls/796/commits","review_comments_url":"https://api.github.com/repos/square/retrofit/pulls/796/comments","review_comment_url":"https://api.github.com/repos/square/retrofit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/retrofit/issues/796/comments","statuses_url":"https://api.github.com/repos/square/retrofit/statuses/cdbf6dff20e4fbffd008800b15df6d4d7f066216","head":{"label":"google:deferthethings","ref":"deferthethings","sha":"cdbf6dff20e4fbffd008800b15df6d4d7f066216","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":23710577,"name":"retrofit","full_name":"google/retrofit","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/retrofit","description":"Type-safe REST client for Android and Java by Square, Inc.","fork":true,"url":"https://api.github.com/repos/google/retrofit","forks_url":"https://api.github.com/repos/google/retrofit/forks","keys_url":"https://api.github.com/repos/google/retrofit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/retrofit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/retrofit/teams","hooks_url":"https://api.github.com/repos/google/retrofit/hooks","issue_events_url":"https://api.github.com/repos/google/retrofit/issues/events{/number}","events_url":"https://api.github.com/repos/google/retrofit/events","assignees_url":"https://api.github.com/repos/google/retrofit/assignees{/user}","branches_url":"https://api.github.com/repos/google/retrofit/branches{/branch}","tags_url":"https://api.github.com/repos/google/retrofit/tags","blobs_url":"https://api.github.com/repos/google/retrofit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/retrofit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/retrofit/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/retrofit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/retrofit/statuses/{sha}","languages_url":"https://api.github.com/repos/google/retrofit/languages","stargazers_url":"https://api.github.com/repos/google/retrofit/stargazers","contributors_url":"https://api.github.com/repos/google/retrofit/contributors","subscribers_url":"https://api.github.com/repos/google/retrofit/subscribers","subscription_url":"https://api.github.com/repos/google/retrofit/subscription","commits_url":"https://api.github.com/repos/google/retrofit/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/retrofit/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/retrofit/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/retrofit/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/retrofit/contents/{+path}","compare_url":"https://api.github.com/repos/google/retrofit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/retrofit/merges","archive_url":"https://api.github.com/repos/google/retrofit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/retrofit/downloads","issues_url":"https://api.github.com/repos/google/retrofit/issues{/number}","pulls_url":"https://api.github.com/repos/google/retrofit/pulls{/number}","milestones_url":"https://api.github.com/repos/google/retrofit/milestones{/number}","notifications_url":"https://api.github.com/repos/google/retrofit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/retrofit/labels{/name}","releases_url":"https://api.github.com/repos/google/retrofit/releases{/id}","created_at":"2014-09-05T16:45:45Z","updated_at":"2015-04-16T14:00:29Z","pushed_at":"2015-03-27T16:58:27Z","git_url":"git://github.com/google/retrofit.git","ssh_url":"git@github.com:google/retrofit.git","clone_url":"https://github.com/google/retrofit.git","svn_url":"https://github.com/google/retrofit","homepage":"http://square.github.io/retrofit/","size":2301,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":12,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"bfeaaa5c67c65fcad643d69ec552d811eafd05ea","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":892275,"name":"retrofit","full_name":"square/retrofit","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/retrofit","description":"Type-safe REST client for Android and Java by Square, Inc.","fork":false,"url":"https://api.github.com/repos/square/retrofit","forks_url":"https://api.github.com/repos/square/retrofit/forks","keys_url":"https://api.github.com/repos/square/retrofit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/retrofit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/retrofit/teams","hooks_url":"https://api.github.com/repos/square/retrofit/hooks","issue_events_url":"https://api.github.com/repos/square/retrofit/issues/events{/number}","events_url":"https://api.github.com/repos/square/retrofit/events","assignees_url":"https://api.github.com/repos/square/retrofit/assignees{/user}","branches_url":"https://api.github.com/repos/square/retrofit/branches{/branch}","tags_url":"https://api.github.com/repos/square/retrofit/tags","blobs_url":"https://api.github.com/repos/square/retrofit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/retrofit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/retrofit/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/retrofit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/retrofit/statuses/{sha}","languages_url":"https://api.github.com/repos/square/retrofit/languages","stargazers_url":"https://api.github.com/repos/square/retrofit/stargazers","contributors_url":"https://api.github.com/repos/square/retrofit/contributors","subscribers_url":"https://api.github.com/repos/square/retrofit/subscribers","subscription_url":"https://api.github.com/repos/square/retrofit/subscription","commits_url":"https://api.github.com/repos/square/retrofit/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/retrofit/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/retrofit/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/retrofit/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/retrofit/contents/{+path}","compare_url":"https://api.github.com/repos/square/retrofit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/retrofit/merges","archive_url":"https://api.github.com/repos/square/retrofit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/retrofit/downloads","issues_url":"https://api.github.com/repos/square/retrofit/issues{/number}","pulls_url":"https://api.github.com/repos/square/retrofit/pulls{/number}","milestones_url":"https://api.github.com/repos/square/retrofit/milestones{/number}","notifications_url":"https://api.github.com/repos/square/retrofit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/retrofit/labels{/name}","releases_url":"https://api.github.com/repos/square/retrofit/releases{/id}","created_at":"2010-09-06T21:39:43Z","updated_at":"2015-04-17T02:01:26Z","pushed_at":"2015-04-16T21:58:54Z","git_url":"git://github.com/square/retrofit.git","ssh_url":"git@github.com:square/retrofit.git","clone_url":"https://github.com/square/retrofit.git","svn_url":"https://github.com/square/retrofit","homepage":"http://square.github.io/retrofit/","size":60715,"stargazers_count":4967,"watchers_count":4967,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":833,"mirror_url":null,"open_issues_count":63,"forks":833,"open_issues":63,"watchers":4967,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/retrofit/pulls/796"},"html":{"href":"https://github.com/square/retrofit/pull/796"},"issue":{"href":"https://api.github.com/repos/square/retrofit/issues/796"},"comments":{"href":"https://api.github.com/repos/square/retrofit/issues/796/comments"},"review_comments":{"href":"https://api.github.com/repos/square/retrofit/pulls/796/comments"},"review_comment":{"href":"https://api.github.com/repos/square/retrofit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/retrofit/pulls/796/commits"},"statuses":{"href":"https://api.github.com/repos/square/retrofit/statuses/cdbf6dff20e4fbffd008800b15df6d4d7f066216"}}}}