-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix-2 #2
base: master
Are you sure you want to change the base?
Conversation
hifeful
commented
Jun 28, 2023
- MyMealsFragment.kt was reimplemented to use custom MVI with Flows instead of MVICore's solution
- Coroutines were added
- Other small fixes
…nstead of MVICore's solution - Coroutines were added - Other small fixes
app/src/main/java/com/hifeful/mealmania/presentation/myMeals/MyMealsFragmentBinder.kt
Outdated
Show resolved
Hide resolved
binding.bind(it, recentMealsAdapter, favouriteMealsAdapter) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct ✅
Just FYI: there is the alternative of Flow.flowWithLifecycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 No action required
app/src/main/java/com/hifeful/mealmania/presentation/myMeals/MyMealsViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/hifeful/mealmania/presentation/myMeals/MyMealsViewModel.kt
Outdated
Show resolved
Hide resolved
when (event) { | ||
is MyMealsEvent.LoadRecentMeals -> mealsRepository.getRecentMeals() | ||
.subscribeOn(Schedulers.computation()) | ||
.observeOn(AndroidSchedulers.mainThread()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we have Rx and Coroutines together, we should convert Rx into Coroutine.
That way, we gonna have control of threads and easily debug and handle any errors.
👌 The known and checked solution of how to do this conversion is using suspendCoroutine:
suspendCoroutine { continuation ->
try {
continuation.resume(mealsRepository.getRecentMeals().blockingGet())
} catch (cancellation: CancellationException) {
continuation.resumeWithException(cancellation)
} catch (failure: Exception) {
// handle error somehow (for instance, map to custom error type)
continuation.resumeWithException(cancellation)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No action is required for now
As threading will be in another module soon
- fixes in MyMealsViewModel.kt