DEV Community

Retrying failed requests in Elm... without the headache

1hko on June 29, 2018

I needed a generic way to retry requests that fail. I did not want to litter my model with extra state or clutter my update function by having to h...
Collapse
 
kspeakman profile image
Kasey Speakman

Nice post.

I don't immediately see any technical problems. I think you will have to deal with Tasks to support the functionality, but you could provide your own function on Retry to turn it into a Cmd Msg.

Based on my experience, automatic retries can by problematic for user experience. It can make sense in scenarios like trying to sync some data in the background. But in cases where the user is waiting on the response, I like to notify users of any problem and leave their page/data in a state where they can choose to retry themselves.

Just my 2 cents, FWIW.

Collapse
 
1hko profile image
1hko

Helpful feedback, thank you. Maybe something like "Automatically retrying in X sec ..." combined with a "Retry now" button. Now that we talk about it, I feel like I've seen this kind of "retry" interface many times. I didn't realize I already had a good example to guide me!