GitHunt
JO

joost-klitsie/DataLoadingExample

An example how to use a reactive way of data loading inside your view models, while consuming the data from a Composable view.

This is example code to showcase a reactive aproach to load data into a View Model.

The full article can be found on Medium

If you run the project, you will see a screen that can:

  1. Load data from memory directly if it is there
  2. Load data from another source if data is not available in memory
  3. Offer retry mechanism if data fails to load
  4. After data successfully is loaded, updates to the data will populate the screen
  5. You can refresh data by pushing a button
  6. If refreshing data fails, you are informed.

In the example project loading of data is randomized, giving you a 50/50 chance of successfully loading data.
In the following GIF's you will see the behavior described above:

loaded_at_start-ezgif com-video-to-gif-converter loading_success-ezgif com-video-to-gif-converter loading_with_failure-ezgif com-video-to-gif-converter

Contributors

Created July 26, 2024
Updated February 9, 2026
joost-klitsie/DataLoadingExample | GitHunt