Skip to content

Commit 19ccfe0

Browse files
committed
change hilt module scope [FoKE-Developers#73]
- repository가 한번의 call 이후 메모리에서 사라지는 것으로 보여 Singleton으로 변경
1 parent ec41cca commit 19ccfe0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

data/src/main/java/com/foke/together/data/repository/di/RepositoryModule.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import com.foke.together.domain.output.RemoteRepositoryInterface
77
import dagger.Binds
88
import dagger.Module
99
import dagger.hilt.InstallIn
10-
import dagger.hilt.android.components.ViewModelComponent
10+
import dagger.hilt.components.SingletonComponent
11+
import javax.inject.Singleton
1112

1213
@Module
13-
@InstallIn(ViewModelComponent::class)
14+
@InstallIn(SingletonComponent::class)
1415
abstract class RepositoryModule {
16+
@Singleton
1517
@Binds
1618
abstract fun bindAppPreferenceRepository(appPreferenceRepository: AppPreferencesRepository): AppPreferenceInterface
1719

20+
@Singleton
1821
@Binds
1922
abstract fun bindRemoteRepository(remoteRepository: RemoteRepository): RemoteRepositoryInterface
2023
}

external/src/main/java/com/foke/together/external/repository/di/RepositoryModule.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import com.foke.together.external.repository.ExternalCameraRepository
55
import dagger.Binds
66
import dagger.Module
77
import dagger.hilt.InstallIn
8-
import dagger.hilt.android.components.ViewModelComponent
8+
import dagger.hilt.components.SingletonComponent
9+
import javax.inject.Singleton
910

1011
@Module
11-
@InstallIn(ViewModelComponent::class)
12+
@InstallIn(SingletonComponent::class)
1213
abstract class RepositoryModule {
14+
@Singleton
1315
@Binds
1416
abstract fun bindAppPreferenceRepository(
1517
externalCameraRepository: ExternalCameraRepository

0 commit comments

Comments
 (0)