Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix-2 #2

wants to merge 2 commits into from

Conversation

hifeful
Copy link
Owner

@hifeful 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
binding.bind(it, recentMealsAdapter, favouriteMealsAdapter)
}
}
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 No action required

when (event) {
is MyMealsEvent.LoadRecentMeals -> mealsRepository.getRecentMeals()
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())

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)
    }
 }

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

@lus-ence lus-ence mentioned this pull request Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants