{"action":"opened","issue":{"url":"https://api.github.com/repos/listenzz/Live/issues/1","repository_url":"https://api.github.com/repos/listenzz/Live","labels_url":"https://api.github.com/repos/listenzz/Live/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/listenzz/Live/issues/1/comments","events_url":"https://api.github.com/repos/listenzz/Live/issues/1/events","html_url":"https://github.com/listenzz/Live/issues/1","id":277650549,"number":1,"title":"检查主线程问题","user":{"login":"Blankeer","id":8948303,"avatar_url":"https://avatars0.githubusercontent.com/u/8948303?v=4","gravatar_id":"","url":"https://api.github.com/users/Blankeer","html_url":"https://github.com/Blankeer","followers_url":"https://api.github.com/users/Blankeer/followers","following_url":"https://api.github.com/users/Blankeer/following{/other_user}","gists_url":"https://api.github.com/users/Blankeer/gists{/gist_id}","starred_url":"https://api.github.com/users/Blankeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Blankeer/subscriptions","organizations_url":"https://api.github.com/users/Blankeer/orgs","repos_url":"https://api.github.com/users/Blankeer/repos","events_url":"https://api.github.com/users/Blankeer/events{/privacy}","received_events_url":"https://api.github.com/users/Blankeer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-29T07:07:04Z","updated_at":"2017-11-29T07:07:04Z","closed_at":null,"author_association":"NONE","body":"我写的以下代码, x 时间后执行 xx 操作\r\n```java\r\n        Observable.timer(2000, TimeUnit.MILLISECONDS)\r\n                .compose(Live.bindLifecycle(this))\r\n                .subscribe({\r\n                    LogUtil.d(\"ok\")\r\n                    //....\r\n                }, {\r\n                    LogUtil.e(it)\r\n                })\r\n```\r\n看起来貌似没有问题,但是执行后,没有任何输出,`onNext`和`onError`都没有被回调,关键是没有任何报错.\r\n\r\n看了下源码,跟踪了一下,原因: Live.java#67 `assertMainThread();`判断当前线程是否为主线程,不是就报错.而我上述的代码,onNext 执行是不在主线程上的,所以这里抛异常了,但是!`onError`没有收到这个异常信息!!\r\n\r\n解决办法: 在`compose(Live.bindLifecycle(this))`前加上`.observeOn(AndroidSchedulers.mainThread())`\r\n\r\n望优化异常处理."}}
{"actor":{"display_login":"Blankeer"}}