{"action":"created","issue":{"url":"https://api.github.com/repos/square/retrofit/issues/1104","labels_url":"https://api.github.com/repos/square/retrofit/issues/1104/labels{/name}","comments_url":"https://api.github.com/repos/square/retrofit/issues/1104/comments","events_url":"https://api.github.com/repos/square/retrofit/issues/1104/events","html_url":"https://github.com/square/retrofit/issues/1104","id":107625776,"number":1104,"title":"Does RxJava adapted requests observe on main thread?","user":{"login":"xingrz","id":288288,"avatar_url":"https://avatars.githubusercontent.com/u/288288?v=3","gravatar_id":"","url":"https://api.github.com/users/xingrz","html_url":"https://github.com/xingrz","followers_url":"https://api.github.com/users/xingrz/followers","following_url":"https://api.github.com/users/xingrz/following{/other_user}","gists_url":"https://api.github.com/users/xingrz/gists{/gist_id}","starred_url":"https://api.github.com/users/xingrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xingrz/subscriptions","organizations_url":"https://api.github.com/users/xingrz/orgs","repos_url":"https://api.github.com/users/xingrz/repos","events_url":"https://api.github.com/users/xingrz/events{/privacy}","received_events_url":"https://api.github.com/users/xingrz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-22T00:48:19Z","updated_at":"2015-09-22T02:03:10Z","closed_at":null,"body":"I just configured Retrofit 2 with RxJava adapter as below\r\n\r\n```java\r\nretrofit = new Retrofit.Builder()\r\n        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())\r\n        /* ... */\r\n```\r\n\r\nand my service interface:\r\n\r\n```java\r\npublic interface FeedApi {\r\n\r\n    @GET(\"v1/feed/timeline/\")\r\n    Observable<FeedEnvelope> timeline(@Query(\"max_id\") String maxId);\r\n\r\n}\r\n```\r\n\r\nThen I make a request in my Activity and populate the result into a RecyclerView adapter like below:\r\n\r\n```java\r\nfeedApi.timeline(null)\r\n        .subscribe(envelope -> myRecyclerAdapter.setItems(envelope.items));\r\n```\r\n\r\nThat RecyclerView didn't render the result until I manually scroll it.\r\n\r\nBut code below works:\r\n\r\n```java\r\nfeedApi.timeline(null)\r\n        .observeOn(AndroidSchedulers.mainThread())\r\n        .subscribeOn(Schedulers.io())\r\n        .subscribe(envelope -> myRecyclerAdapter.setItems(envelope.items));\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/square/retrofit/issues/comments/142159155","html_url":"https://github.com/square/retrofit/issues/1104#issuecomment-142159155","issue_url":"https://api.github.com/repos/square/retrofit/issues/1104","id":142159155,"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},"created_at":"2015-09-22T02:03:10Z","updated_at":"2015-09-22T02:03:10Z","body":"No. It calls back on a background thread. You need to observe it on the\nmain thread. You do not need to provide a subscription scheduler, it's\nalways on a background thread.\n\nOn Mon, Sep 21, 2015, 8:48 PM XiNGRZ <notifications@github.com> wrote:\n\n> I just configured Retrofit 2 with RxJava adapter as below\n>\n> retrofit = new Retrofit.Builder()\n>         .addCallAdapterFactory(RxJavaCallAdapterFactory.create())\n>         /* ... */\n>\n> and my service interface:\n>\n> public interface FeedApi {\n>\n>     @GET(\"v1/feed/timeline/\")\n>     Observable<FeedEnvelope> timeline(@Query(\"max_id\") String maxId);\n>\n> }\n>\n> Then I make a request in my Activity and populate the result into a\n> RecyclerView adapter like below:\n>\n> feedApi.timeline(null)\n>         .subscribe(envelope -> myRecyclerAdapter.setItems(envelope.items));\n>\n> That RecyclerView didn't render the result until I manually scroll it.\n>\n> But code below works:\n>\n> feedApi.timeline(null)\n>         .observeOn(AndroidSchedulers.mainThread())\n>         .subscribeOn(Schedulers.io())\n>         .subscribe(envelope -> myRecyclerAdapter.setItems(envelope.items));\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/square/retrofit/issues/1104>.\n>\n"}}