Colton Idle
09/13/2024, 4:46 PMclass RollerToasterApplication : Application() {
private val job = SupervisorJob()
private val appScope = CoroutineScope(Dispatchers.Default + job)
private val appStateHolder = AppStateHolder(appScope)
// onCreate() calls appStateHolder.initialize()
then in AppStateHolder.kt I have
class AppStateHolder(
val appScope: CoroutineScope
) {
fun initialize() {
appScope.launch {
...
Any critiques with that approach... I think it seems to make sense and it is testable since the scope isn't being hardcode in AppStateHolder?yschimke
09/13/2024, 4:51 PMyschimke
09/13/2024, 4:52 PMColton Idle
09/13/2024, 5:11 PMColton Idle
09/13/2024, 5:12 PMyschimke
09/13/2024, 5:12 PMColton Idle
09/13/2024, 5:14 PMColton Idle
09/13/2024, 5:14 PMyschimke
09/13/2024, 5:19 PMyschimke
09/13/2024, 5:19 PMColton Idle
09/13/2024, 5:22 PMAlex Vanyo
09/13/2024, 6:03 PMDataStore
accepts a CoroutineScope
directly in its constructor, and in Now in Android we inject a singleton CoroutineScope
for it: https://github.com/android/nowinandroid/blob/447cd7eba311c9cb4b4f302bf632fe8bd4e97[…]ples/apps/nowinandroid/core/network/di/CoroutineScopesModule.ktColton Idle
09/13/2024, 6:26 PM