Skip to content
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

♻️ Remove duplicated CoroutineScope #385

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/src/main/java/com/escodro/alkaa/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package com.escodro.alkaa.di
import com.escodro.alkaa.presentation.MainViewModel
import com.escodro.alkaa.presentation.mapper.AppThemeOptionsMapper
import com.escodro.core.coroutines.ApplicationScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.SupervisorJob
import org.koin.androidx.viewmodel.dsl.viewModelOf
import org.koin.core.module.dsl.factoryOf
import org.koin.dsl.module
Expand All @@ -14,8 +12,6 @@ import org.koin.dsl.module
* Application module.
*/
val appModule = module {
factory { CoroutineScope(SupervisorJob()) }

viewModelOf(::MainViewModel)

factoryOf(::AppThemeOptionsMapper)
Expand Down
4 changes: 3 additions & 1 deletion data/local/src/main/java/com/escodro/local/di/LocalModule.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.escodro.local.di

import com.escodro.core.coroutines.ApplicationScope
import com.escodro.local.datasource.CategoryLocalDataSource
import com.escodro.local.datasource.SearchLocalDataSource
import com.escodro.local.datasource.TaskLocalDataSource
Expand All @@ -14,6 +15,7 @@ import com.escodro.repository.datasource.CategoryDataSource
import com.escodro.repository.datasource.SearchDataSource
import com.escodro.repository.datasource.TaskDataSource
import com.escodro.repository.datasource.TaskWithCategoryDataSource
import org.koin.android.ext.koin.androidContext
import org.koin.core.module.dsl.factoryOf
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.bind
Expand All @@ -37,6 +39,6 @@ val localModule = module {
factoryOf(::TaskWithCategoryMapper)

// Providers
singleOf(::DatabaseProvider)
single { DatabaseProvider(context = androidContext(), coroutineScope = get(ApplicationScope)) }
singleOf(::DaoProvider)
}
1 change: 1 addition & 0 deletions features/alarm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies {
implementation(projects.features.alarmApi)
implementation(projects.libraries.core)
implementation(projects.libraries.navigation)
implementation(projects.libraries.core)
implementation(projects.domain)

implementation(libs.kotlinx.coroutines.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.AlarmManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.escodro.core.coroutines.ApplicationScope
import com.escodro.domain.usecase.alarm.RescheduleFutureAlarms
import com.escodro.domain.usecase.alarm.ShowAlarm
import com.escodro.domain.usecase.alarm.SnoozeAlarm
Expand All @@ -20,7 +21,7 @@ import org.koin.core.component.inject
*/
internal class TaskReceiver : BroadcastReceiver(), KoinComponent {

private val coroutineScope: CoroutineScope by inject()
private val coroutineScope: CoroutineScope by inject(qualifier = ApplicationScope)

private val completeTaskUseCase: CompleteTask by inject()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import org.koin.dsl.module
*/
val categoryModule = module {
viewModelOf(::CategoryListViewModelImpl) bind CategoryListViewModel::class
viewModelOf(::CategoryAddViewModel)
viewModel {
CategoryAddViewModel(
addCategoryUseCase = get(),
applicationScope = get(ApplicationScope),
categoryMapper = get()
)
}
viewModel {
CategoryEditViewModel(
loadCategoryUseCase = get(),
Expand Down
1 change: 1 addition & 0 deletions features/glance/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
dependencies {
implementation(projects.domain)
implementation(projects.libraries.navigation)
implementation(projects.libraries.core)

implementation(libs.koin.android)
implementation(libs.koin.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,26 @@ import androidx.glance.state.GlanceStateDefinition
import androidx.glance.text.Text
import androidx.glance.text.TextStyle
import androidx.glance.unit.ColorProvider
import com.escodro.core.coroutines.ApplicationScope
import com.escodro.glance.R
import com.escodro.glance.data.TaskListStateDefinition
import com.escodro.glance.model.Task
import com.escodro.navigation.DestinationDeepLink
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

internal class TaskListGlanceWidget : GlanceAppWidget(), KoinComponent {

private val coroutineScope: CoroutineScope = MainScope()
private val coroutineScope: CoroutineScope by inject(qualifier = ApplicationScope)

/**
* Custom implementation of [GlanceStateDefinition] to save and store data for this widget.
*/
override val stateDefinition: GlanceStateDefinition<ImmutableList<Task>> = TaskListStateDefinition
override val stateDefinition: GlanceStateDefinition<ImmutableList<Task>> =
TaskListStateDefinition

@Composable
override fun Content() {
Expand Down