A few months ago, I asked this question (which I can’t find in Slack anymore):
Background: Lifecycle of a RemoteData.WebData
Set value as NotAsked initially
When making API call, set value as Loading
When API result comes back
a. If error, set value as Failure
b. If success, set value as Success
When firing off an API call, we need to anticipate which model fields are going to be affected and preemptively set them as RemoteData.Loading.
I find this wiring quite fragile. e.g. if I forget to set thing = RemoteData.Loading here, everything compiles. Or if update changes and now this API affects more/fewer fields, how do I remember to make corresponding updates in other places?
Is there a way to make this more robust?
My coworker jsegura and I recently stumbled upon this approach while recalling this dissatisfaction. Looking for feedback or better approaches