Skip to content
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

LifecycleScope 移除 Observer 的疑问 #25

Open
gentrio opened this issue Aug 2, 2023 · 8 comments
Open

LifecycleScope 移除 Observer 的疑问 #25

gentrio opened this issue Aug 2, 2023 · 8 comments

Comments

@gentrio
Copy link

gentrio commented Aug 2, 2023

LifecycleScope 为什么要在 onScopeStart 方法中执行 onScopeEnd 去主动移除 observer 监听,然后重新添加?

@gentrio
Copy link
Author

gentrio commented Aug 2, 2023

WX20230802-204502@2x

@liujingxing
Copy link
Owner

看起来确实是多余的,应该是手误,容我再回忆回忆

@gentrio
Copy link
Author

gentrio commented Aug 2, 2023

还有一个点想跟老哥讨论一下,我看RxHttp和RxLife封装的Observer都对onNext做了try catch,我onNext里处理逻辑抛出异常,同样会走onError处理逻辑,这样的话相当于onNext和onError都触发了,两者并不是互斥的,就是这么设计的吗?

@liujingxing
Copy link
Owner

是的,RxJava就是这么设计的

@gentrio
Copy link
Author

gentrio commented Aug 2, 2023

我刚有看Rxjava的设计,当传入onNext consumer和onError consumer 异常是会被捕获因为封装了一层observer,前提未进行线程切换,但如果使用自定义Observe异常是捕获不住的。

@liujingxing
Copy link
Owner

前提未进行线程切换?这句话我没看懂

@gentrio
Copy link
Author

gentrio commented Aug 2, 2023

线程切换这点理解有误,主要还是看Observer的处理机制

@liujingxing
Copy link
Owner

是的,onError/onComplete才是互斥的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants