Skip to content

Commit 67b6387

Browse files
committed
build: 피쳐모듈 페이징 의존성 추가
1 parent 1bfdb88 commit 67b6387

File tree

1 file changed

+75
-75
lines changed

1 file changed

+75
-75
lines changed
Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
package com.into.websoso.data.library.datasource
2-
3-
import com.into.websoso.data.library.model.NovelEntity
4-
import dagger.Binds
5-
import dagger.Module
6-
import dagger.hilt.InstallIn
7-
import dagger.hilt.components.SingletonComponent
8-
import kotlinx.coroutines.flow.Flow
9-
import kotlinx.coroutines.flow.MutableStateFlow
10-
import kotlinx.coroutines.flow.asStateFlow
11-
import kotlinx.coroutines.flow.update
12-
import javax.inject.Inject
13-
import javax.inject.Singleton
14-
15-
@Singleton
16-
class DefaultLibraryLocalDataSource
17-
@Inject
18-
constructor() : LibraryLocalDataSource {
19-
private val cachedNovels = MutableStateFlow<List<NovelEntity>>(emptyList())
20-
21-
override suspend fun insertNovels(novels: List<NovelEntity>) {
22-
cachedNovels.update { currentNovels ->
23-
(currentNovels + novels).distinctBy { it.novelId }
24-
}
25-
}
26-
27-
override suspend fun insertNovel(novel: NovelEntity) {
28-
cachedNovels.update { currentNovels ->
29-
if (currentNovels.any { it.novelId == novel.novelId }) return
30-
(currentNovels + novel).distinctBy { it.novelId }
31-
}
32-
}
33-
34-
override fun selectAllNovels(): Flow<List<NovelEntity>> = cachedNovels.asStateFlow()
35-
36-
override suspend fun selectNovel(novelId: Long): NovelEntity? =
37-
cachedNovels.value.find { currentNovel ->
38-
currentNovel.novelId == novelId
39-
}
40-
41-
override suspend fun updateNovels(novels: List<NovelEntity>) {
42-
cachedNovels.update { currentNovels ->
43-
val updatedNovels = novels.associateBy { it.novelId }
44-
currentNovels.map { currentNovel ->
45-
updatedNovels[currentNovel.novelId] ?: currentNovel
46-
}
47-
}
48-
}
49-
50-
override suspend fun updateNovel(novel: NovelEntity) {
51-
cachedNovels.update { currentNovels ->
52-
currentNovels.map { currentNovel ->
53-
if (currentNovel.novelId == novel.novelId) novel else currentNovel
54-
}
55-
}
56-
}
57-
58-
override suspend fun deleteAllNovels() {
59-
cachedNovels.value = emptyList()
60-
}
61-
62-
override suspend fun deleteNovel(novelId: Long) {
63-
cachedNovels.update { currentNovels ->
64-
currentNovels.filterNot { currentNovel -> currentNovel.novelId == novelId }
65-
}
66-
}
67-
}
68-
69-
@Module
70-
@InstallIn(SingletonComponent::class)
71-
internal interface LibraryDataSourceModule {
72-
@Binds
73-
@Singleton
74-
fun bindLibraryLocalDataSource(defaultLibraryLocalDataSource: DefaultLibraryLocalDataSource): LibraryLocalDataSource
75-
}
1+
//package com.into.websoso.data.library.datasource
2+
//
3+
//import com.into.websoso.data.library.model.NovelEntity
4+
//import dagger.Binds
5+
//import dagger.Module
6+
//import dagger.hilt.InstallIn
7+
//import dagger.hilt.components.SingletonComponent
8+
//import kotlinx.coroutines.flow.Flow
9+
//import kotlinx.coroutines.flow.MutableStateFlow
10+
//import kotlinx.coroutines.flow.asStateFlow
11+
//import kotlinx.coroutines.flow.update
12+
//import javax.inject.Inject
13+
//import javax.inject.Singleton
14+
//
15+
//@Singleton
16+
//class DefaultLibraryLocalDataSource
17+
// @Inject
18+
// constructor() : LibraryLocalDataSource {
19+
// private val cachedNovels = MutableStateFlow<List<NovelEntity>>(emptyList())
20+
//
21+
// override suspend fun insertNovels(novels: List<NovelEntity>) {
22+
// cachedNovels.update { currentNovels ->
23+
// (currentNovels + novels).distinctBy { it.novelId }
24+
// }
25+
// }
26+
//
27+
// override suspend fun insertNovel(novel: NovelEntity) {
28+
// cachedNovels.update { currentNovels ->
29+
// if (currentNovels.any { it.novelId == novel.novelId }) return
30+
// (currentNovels + novel).distinctBy { it.novelId }
31+
// }
32+
// }
33+
//
34+
// override fun selectAllNovels(): Flow<List<NovelEntity>> = cachedNovels.asStateFlow()
35+
//
36+
// override suspend fun selectNovel(novelId: Long): NovelEntity? =
37+
// cachedNovels.value.find { currentNovel ->
38+
// currentNovel.novelId == novelId
39+
// }
40+
//
41+
// override suspend fun updateNovels(novels: List<NovelEntity>) {
42+
// cachedNovels.update { currentNovels ->
43+
// val updatedNovels = novels.associateBy { it.novelId }
44+
// currentNovels.map { currentNovel ->
45+
// updatedNovels[currentNovel.novelId] ?: currentNovel
46+
// }
47+
// }
48+
// }
49+
//
50+
// override suspend fun updateNovel(novel: NovelEntity) {
51+
// cachedNovels.update { currentNovels ->
52+
// currentNovels.map { currentNovel ->
53+
// if (currentNovel.novelId == novel.novelId) novel else currentNovel
54+
// }
55+
// }
56+
// }
57+
//
58+
// override suspend fun deleteAllNovels() {
59+
// cachedNovels.value = emptyList()
60+
// }
61+
//
62+
// override suspend fun deleteNovel(novelId: Long) {
63+
// cachedNovels.update { currentNovels ->
64+
// currentNovels.filterNot { currentNovel -> currentNovel.novelId == novelId }
65+
// }
66+
// }
67+
// }
68+
//
69+
//@Module
70+
//@InstallIn(SingletonComponent::class)
71+
//internal interface LibraryDataSourceModule {
72+
// @Binds
73+
// @Singleton
74+
// fun bindLibraryLocalDataSource(defaultLibraryLocalDataSource: DefaultLibraryLocalDataSource): LibraryLocalDataSource
75+
//}

0 commit comments

Comments
 (0)