-
Notifications
You must be signed in to change notification settings - Fork 187
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
关于BaseRepo和BaseViewModel中launch函数的封装 #11
Comments
首先非常感谢您提的建议,这对我非常有用。 关于第二点和第三点我跟你意见基本一致,所以我本地已经标了Deprecated,很快就会被剔除 |
欢迎以后多提建议啊,大家共同进步。 ~_~ |
BaseRepo里面个人认为使用flow代替livedata是否更合适。 |
关于flow现在还在了解阶段,后面会考虑引入 |
首先赞一下大佬掘金的两篇高质量文章。
看了下代码,对
launch{}
这个封装 有几个小建议:一是
Dispatcher
建议手动传入,这样使用者更明确block: suspend () -> T的执行环境二是 success和error这两个callback的线程环境建议统一下,比如要么与block: suspend () -> T 相同,要么统一切换到主线程。
三是
这里
toast(errorMessage) errorLiveData.value = this
可能有bug哈 建议用withContext(Dispatchers.Main.immediate)
包一下The text was updated successfully, but these errors were encountered: