Android Weekly Issue #460
Common Design Patterns and App Architectures for Android
- 一些设计模式在Android中的应用.
- Android的几个patterns. MVC, MVVM, Clean Architecture.
Avoid launchIn
这段代码:
events.filterIsInstance<CloseClicked>()
.onEach { navigator.goTo(Finish()) }
.launchIn(coroutineScope)
可以替换成:
coroutineScope.launch {
events.first { it is CloseClicked }
navigator.goTo(Finish())
}
或者:
coroutineScope.launch {
events.filterIsInstance<CloseClicked>()
.collect { navigator.goTo(Finish()) }
}
Modular Navigation with Jetpack Compose
Compose的理想世界应该是摆脱了Fragment的.
官方提供的Compose Navigation有一些缺点比如:
- 需要依赖navHostController.
- 不好测试.
作者受到这篇文章的启发, 准备探索一下多个modules项目中, compose导航的解决方案.
作者做了一个例子来探索这个方案: https://github.com/hitherejoe/minimise
强烈推荐这篇文章!!
Implementing Snackbar to undo actions in Jetpack Compose
Compose的snackbar + undo.
Scoped recomposition in Jetpack Compose
关于Jetpack Compose的一个小探讨.
结论: 看官方的建议: https://developer.android.com/jetpack/compose/state
不要担心太多.
Using Compose Beta on AS 4.1
不升级IDE也能用上Compose的方法.
ki: The Next Interactive Shell for Kotlin
https://github.com/Kotlin/kotlin-interactive-shell
Libraries & Code
- https://github.com/patilsiddhesh/Holi 颜色库
- https://github.com/cbeust/kash kotlin写的shell.
- https://github.com/cashapp/InflationInject Constructor-inject views during XML layout inflation