Android Weekly Issue #415
SavedStateHandle to the Rescue
自带的:
class SearchFragment: Fragment{
private val vm: SavedStateViewModel by viewModels()
}
class SavedStateViewModel(
private val state: SavedStateHandle
) : ViewModel()
和依赖注入框架如何结合呢?
文中给出了解决方案.
本期还有另一个文章也是说这个事情:
Leveraging AssistedInjection to inject ViewModels
Android Unidirectional Data Flow — Kotlin Flow vs. RxJava
Flow和Rx的对比.
StateFlow, End of LiveData?
Kotlin协程库的StateFlow.
例子: https://github.com/scalereal/StateFlow-Demo
Reification of the Erased
Java中的泛型擦除.
reified
必须和inline方法一起.
有reified
类型的内联方法, 编译器会拷贝方法体, 并且把泛型类型替换成声明的类型.
Java不支持inline, 所以不支持这样的特性.
The Result Monad
一个叫做: kotlin-result的库
Code
Decorator: RecyclerView的Decorator.
静态检查插件: https://github.com/GradleUp/static-analysis-plugin
变形动画: https://github.com/skydoves/TransformationLayout
Jetpack Compose的playground: https://github.com/hitherejoe/ComposeAcademy-Playground