-
Notifications
You must be signed in to change notification settings - Fork 3
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
Introduce kotlin coroutines flow #21
Conversation
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.
Do you show numberOfLikes
in android?
view.showLoader() | ||
getPhotosJob = launchInMain { | ||
try { | ||
logInfo(TAG, "Start getting photos") |
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.
Do we lose the logs? I'd prefer to keep those logs to understand in common module how is going the code in both platforms (android or iOS)
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.
Nevermind 👍
fun onCreate() = launchInMain { | ||
view.render(View.State.Loading) | ||
getAllPhotos() | ||
.flowOnBackground() |
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.
👏 👏 👏
|
||
suspend fun get(): Flow<Photos> = | ||
timer(repeatEvery = updateInterval) | ||
.map { photosApiClient.getPhotos() } |
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.
This is because you emit Unit
but after that, you map it to the Photos you get from .getPhotos()
, right?
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.
Yes, the timer does not emit anything of value, just happens to do it in a convenient interval :)
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.
🚀
📌 References
🎩 What is the goal?
To introduce Flow into the project. The approach is not the best one but we now know this is possible.
📝 How is it being implemented?
render
method and passing a sealed class. This is just an idea for the future I've been having for a while, doing so can make it way easier to test presenter+view interaction with the help of snapshot testing, it's not really needed for this project though.timer
flow that returns aUnit
value with a configurable interval.PhotosFlow
instead of doing it with the API directly.Delay
interface to the iOS Dispatcher. This let us call thedelay
function that we are using in thetimer
flow. The previous implementation would just stop whenever it found a delay, making the app useless in iOS. The new code has been extracted from here.💥 How can it be tested?
Automatically!