Reduce memory footprint of Hilt (#159)

* Remove @Singleton where it is not needed

* Use @AssistedFactory where possible
This commit is contained in:
Kirill Kamakin
2023-07-04 18:22:16 +02:00
committed by GitHub
parent 2bc2bb76e4
commit 2375be0329
55 changed files with 51 additions and 215 deletions

View File

@@ -1,17 +1,16 @@
package gq.kirmanak.mealient.architecture.configuration
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class AppDispatchersImpl @Inject constructor() : AppDispatchers {
override val io = Dispatchers.IO
override val io: CoroutineDispatcher get() = Dispatchers.IO
override val main = Dispatchers.Main
override val main: CoroutineDispatcher get() = Dispatchers.Main
override val default = Dispatchers.Default
override val default: CoroutineDispatcher get() = Dispatchers.Default
override val unconfined = Dispatchers.Unconfined
override val unconfined: CoroutineDispatcher get() = Dispatchers.Unconfined
}

View File

@@ -4,13 +4,11 @@ import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
interface ArchitectureModule {
@Binds
@Singleton
fun bindAppDispatchers(appDispatchersImpl: AppDispatchersImpl): AppDispatchers
}