Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry action? #64

Closed
Noitidart opened this issue Apr 24, 2017 · 4 comments
Closed

Retry action? #64

Noitidart opened this issue Apr 24, 2017 · 4 comments

Comments

@Noitidart
Copy link

Noitidart commented Apr 24, 2017

Is there a way to get a action dispatched when it is retrying? I want to update my GUI to saying it is going to retry in X sec.

I see this logged to console:

'Retrying action', 'FETCH_ENTITY', 'with delay', 1000

Is there a way to make it dispatch an action at the same time? Like *_ROLLBACK and *_COMMIT?


This is an aside, an example of an end goal is:

  1. User takes a screenshot
  2. Clicks upload to Dropbox
  3. It starts the first upload attempt
  4. Now different things can happen
    • If this attempt finds it is offline, I want to show "You are currently offline, will upload when get online"
    • If it is succeeding, I want to show % uploaded
    • If it failed and will retry in X seconds I want to show countdown "Failed will retry in Xs"
    • If it is in "retrying" stages or "waiting for offline" I want to offer a button saying "Cancel upload and instead save to disk"
@benvp
Copy link
Contributor

benvp commented Apr 25, 2017

You could try implement you own discard handler and dispatch an an action here. https://github.com/jevakallio/redux-offline#change-how-irreconcilable-errors-are-detected

Or you could use something like redux-obversables or redux-saga to listen for the Offline/SCHEDULE_RETRY or Offline/COMPLETE_RETRY action and dispatch another action to notify the user,

@Noitidart
Copy link
Author

Ah interesting on the listening to Offline/* - I like to avoid dropping libs, especially redux-saga. Doing store.subscribe should be able to listen for this as well huh? I will try that out. Thanks @benlime!

@benvp
Copy link
Contributor

benvp commented Apr 25, 2017

@Noitidart Maybe it's better to use a middleware for this, as you don't know the action in the subscribe listener. (see reduxjs/redux#1057). If you want to avoid other frameworks, write a middleware which listens for the Offline/* actions and dispatch your actions accordingly.

@Noitidart
Copy link
Author

Oo thanks benlime! Thats very interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants