-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AndroidObservable not work #754
Comments
I'll take this one. The reason it's not working is we're doing a check for whether fromFragment is actually called from the main UI thread, and terminate the Observable if not. However, this check happens in the OnSubscribeFunc so will fail if the wrapped Observable is scheduled to run elsewhere. The check should be moved to the invocation side, i.e. to the fromFragment helper. |
I also got this issue. When it'll be fixed? |
I'm waiting for 0.17 to land; it contains major changes to the Observable API. Will pick it up after. |
Thank for reply! You and your team made a bunch of great work, thanks man! |
@mttkay On this subject, can you confirm that 0.17 (master branch) is working for you on Android. In particular the Android Scheduler was changed by me and I'm not setup to test on real devices. |
I'll have a look ASAP. Has the scheduler rewrite landed yet? It was still |
Yes, it has been merged. Thank you. |
So, I gave this some more thought and I'm not sure we should actually "fix" this. The reason is, After all, these helpers are meant for just one use case: to observe a fully constructed given sequence on the main thread while being able to unsubscribe such that no references to the activity or fragment will leak, plus some additional sanity checks for fragments. I guess that's why I put that guard in to begin with. That being said, I think one problem is the naming. I would suggest the following:
Thoughts on this? @benjchristensen |
@mttkay Thanks for doing that testing for me. I agree that you'll want further testing before production deployment, but the fact that it's good enough to pass right now means there are no major API signature or fatal issues. I am trying to wrap up a few last things so we can release in the next week give or take. |
Sounds good |
@mttkay This code sample below is is taken from your blog post Functional Reactive Programming on Android With RxJava. The code here seems to imply that the
|
Yes that code snippet I wrote before adding the |
That PR already landed. Can we maybe agree that a PR gets at least 2 +1s before we merge it back? I'm not super happy with the changes in there. (see my comments in #880) |
This can be closed as it's fixed in |
- move the UI thread assert out of the operator and into the helpers; this way, we don't fail the observer anymore with an exception, but the caller. - do not loop unsubscribe through the main thread anymore. This unnecessarily defers releasing the references, and might in fact be processed only after Android creates the component after a rotation change. I had to make the references volatile for this to work. - immediately unsubscribe in case we detect the componentRef has become invalid. This solves the problem that dangling observers would continue to listen to notifications with no observer alive anymore. refs: ReactiveX/RxJava#754 ReactiveX/RxJava#899
What I mean of not work is onNext() and onCompleted() not get called.
The text was updated successfully, but these errors were encountered: