An Android Application written purely in Kotlin exploring various usages of Flows and Coroutines in a Real World App.
Follow me on Medium for latest articles.
Medium Article |
---|
Form Validation using Mutable State Flows |
Smart Listener for Shooting requests |
Backoff and Retry Strategy |
- First Name must contain only alphabets.
- Password must be atleast 8 characters long.
- User Id must contain an underscore( _ )
Once all these fields are properly filled only then the Submit button is enabled. The Submit button disables again if any of the fields are edited and the conditions are not met.
For this we use an example of a search query. You don't want to shoot a request whenever the text is edited but wait untill a couple of seconds before shooting a netwiork request.
This way you reduce the number of requests and only return result for the latest text query. For Eg: User may type "Co"..."Coff"..."Coffee". You'd only want to shoot a request when the user has typed the whole word instead of sending a request for every input.
You might come across a situation while developing an app where you’d want to retry a certain request when an Exception occurs without user’s intervention. A pragmatic example would be a case of an IO Exception.
Consider this use case. You want to fetch a list of dogs from the server, however, you get an IO exception due to a network issue. After getting an exception, you wait for a while and then retry. In case of an exception again , you might want to wait a little more than last time and then retry again.
- Exponential Backoff for Network Requests
Support it by starring this repository. ⭐
And follow me on Medium and Github
Find any other use case scenario for Flows? Hit a PR!
This project is founded and actively maintained by Shivam Dhuria.
Got the idea from Kaushik Gopal
- Retrofit2 & OkHttp3 - construct the REST APIs and paging network data.
- Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation.
- Room - For storing Database.