Skip to content

Latest commit

 

History

History
82 lines (52 loc) · 3.53 KB

README.md

File metadata and controls

82 lines (52 loc) · 3.53 KB

State Flows

An Android Application written purely in Kotlin exploring various usages of Flows and Coroutines in a Real World App.

Medium Articles

Follow me on Medium for latest articles.

Medium Article
Form Validation using Mutable State Flows
Smart Listener for Shooting requests
Backoff and Retry Strategy

Cases

Form Validation

The Screen contains three input fields, the **Submit** button is only enabled once all the 3 fields are properly filled.
  • 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.









Smart Listener for Shooting requests

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.

Backoff and Retry Strategy

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.

Tech Stack

Roadmap (Features to be added )

  • Exponential Backoff for Network Requests

Find this repository useful? ❤️

Support it by starring this repository. ⭐
And follow me on Medium and Github

Issues and Contribution

Find any other use case scenario for Flows? Hit a PR!

Project Maintainers

This project is founded and actively maintained by Shivam Dhuria.

Credits

Got the idea from Kaushik Gopal

Libraries

  • 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.