Implementing Stale-While-Revalidate with Rx for API Data Retrieval
Trying to think of a way to express stale-while-revalidate with
1. show some fallback value from a known store, stale value
2. show some initial value if store is empty
3. be able to refresh only the part that actually fetches the api
Satisfying all 3 requirements at the same time in a robust way seems a bit more complicated than it should be.. It seems that either I need at least 2
Rx, but with a few more complications.. Lets say I have an API that returns a list of things. I want to do a few things with that request:1. show some fallback value from a known store, stale value
2. show some initial value if store is empty
3. be able to refresh only the part that actually fetches the api
Satisfying all 3 requirements at the same time in a robust way seems a bit more complicated than it should be.. It seems that either I need at least 2
Rxs to make this work, one to store the state the other to start the state in an implicit manner (run an effect that updates the state correctly) or I need to make concessions around my requirement to make it fit as a stream and optimize around the refreshing behavior using something like Stream.changes