File tree Expand file tree Collapse file tree 4 files changed +7
-6
lines changed
data/src/main/java/com/whyranoid/data/post
domain/src/main/java/com/whyranoid/domain
presentation/src/main/java/com/whyranoid/presentation/community Expand file tree Collapse file tree 4 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ class PostRepositoryImpl @Inject constructor(
23
23
}.flow.cachedIn(coroutineScope)
24
24
}
25
25
26
- override fun getMyPagingPosts (uid : String ): Flow <PagingData <Post >> {
26
+ override fun getMyPagingPosts (uid : String , coroutineScope : CoroutineScope ): Flow <PagingData <Post >> {
27
27
return Pager (
28
28
PagingConfig (pageSize = 5 )
29
29
) {
30
30
PostPagingDataSource (myUid = uid, postDataSource)
31
- }.flow
31
+ }.flow.cachedIn(coroutineScope)
32
32
}
33
33
34
34
override fun getAllPostFlow (): Flow <List <Post >> {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ interface PostRepository {
11
11
// 글(홍보 / 인증) 페이징으로 가져오기 - 리모트
12
12
fun getPagingPosts (coroutineScope : CoroutineScope ): Flow <PagingData <Post >>
13
13
14
- fun getMyPagingPosts (uid : String ): Flow <PagingData <Post >>
14
+ fun getMyPagingPosts (uid : String , coroutineScope : CoroutineScope ): Flow <PagingData <Post >>
15
15
16
16
fun getAllPostFlow (): Flow <List <Post >>
17
17
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import androidx.paging.PagingData
4
4
import com.whyranoid.domain.model.Post
5
5
import com.whyranoid.domain.repository.AccountRepository
6
6
import com.whyranoid.domain.repository.PostRepository
7
+ import kotlinx.coroutines.CoroutineScope
7
8
import kotlinx.coroutines.flow.Flow
8
9
import javax.inject.Inject
9
10
@@ -12,7 +13,7 @@ class GetMyPagingPostsUseCase @Inject constructor(
12
13
private val postRepository : PostRepository
13
14
) {
14
15
15
- suspend operator fun invoke (): Flow <PagingData <Post >> {
16
- return postRepository.getMyPagingPosts(accountRepository.getUid())
16
+ suspend operator fun invoke (coroutineScope : CoroutineScope ): Flow <PagingData <Post >> {
17
+ return postRepository.getMyPagingPosts(accountRepository.getUid(), coroutineScope )
17
18
}
18
19
}
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ internal class CommunityItemFragment :
181
181
}
182
182
183
183
viewLifecycleOwner.repeatWhenUiStarted {
184
- viewModel.getMyPagingPostsUseCase().collectLatest { myPostList ->
184
+ viewModel.getMyPagingPostsUseCase(viewLifecycleOwner.lifecycleScope ).collectLatest { myPostList ->
185
185
postAdapter.submitData(myPostList)
186
186
}
187
187
}
You can’t perform that action at this time.
0 commit comments