File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed
app/src/main/java/com/hoc/pagination_mvi Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,7 @@ package com.hoc.pagination_mvi.data
33import com.hoc.pagination_mvi.data.remote.ApiService
44import com.hoc.pagination_mvi.di.ApplicationScope
55import com.hoc.pagination_mvi.domain.dispatchers_schedulers.CoroutinesDispatchersProvider
6- import com.hoc.pagination_mvi.domain.entity.Photo
76import com.hoc.pagination_mvi.domain.entity.Post
8- import com.hoc.pagination_mvi.domain.repository.PhotoRepository
97import com.hoc.pagination_mvi.domain.repository.PostRepository
108import kotlinx.coroutines.withContext
119import javax.inject.Inject
Original file line number Diff line number Diff line change @@ -94,22 +94,21 @@ class MainInteractorImpl @Inject constructor(
9494 ): Observable <Refresh > {
9595 return rxObservable(dispatchers.main) {
9696 send(Refresh .Refreshing )
97+ try {
98+ coroutineScope {
99+ val async1 = async { getPostsUseCase(limit = limitPost, start = 0 ) }
100+ val async2 = async { getPhotosUseCase(limit = limitPhoto, start = 0 ) }
97101
98- coroutineScope {
99- val async1 = async { getPostsUseCase(limit = limitPost, start = 0 ) }
100- val async2 = async { getPhotosUseCase(limit = limitPhoto, start = 0 ) }
101-
102- try {
103102 send(
104103 Refresh .Success (
105104 posts = async1.await().map(::PostVS ),
106105 photos = async2.await().map(::PhotoVS )
107106 )
108107 )
109- } catch (e: Exception ) {
110- delay(500 )
111- send(Refresh .Error (e))
112108 }
109+ } catch (e: Exception ) {
110+ delay(500 )
111+ send(Refresh .Error (e))
113112 }
114113 }
115114 }
Original file line number Diff line number Diff line change @@ -153,6 +153,10 @@ class MainVM @Inject constructor(
153153 is PostNextPage .Data -> if (change.posts.isEmpty()) singleEventS.onNext(SingleEvent .HasReachedMaxHorizontal )
154154 is PostNextPage .Error -> singleEventS.onNext(SingleEvent .GetPostsFailure (change.error))
155155 PostNextPage .Loading -> Unit
156+ // /
157+ is Refresh .Success -> singleEventS.onNext(SingleEvent .RefreshSuccess )
158+ is Refresh .Error -> singleEventS.onNext(SingleEvent .RefreshFailure (change.error))
159+ Refresh .Refreshing -> Unit
156160 }
157161 }
158162 }
You can’t perform that action at this time.
0 commit comments