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.
- 不好測試.
作者受到這篇文章的啟發(fā), 準備探索一下多個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