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 with a formulated delay #1938

Closed
sayjeyhi opened this issue Sep 19, 2019 · 4 comments
Closed

retry with a formulated delay #1938

sayjeyhi opened this issue Sep 19, 2019 · 4 comments

Comments

@sayjeyhi
Copy link

It could be a good option to pass formulated delay parameter to retry effect.
I mean making delay between call based on counter.
For this purpose , delay parameter could accept function , and pass counter as parameter , then user could return custom delays to every iterate.

retry(maxTries, delay, fn, ...args)

simple use case , we want to retry on 1s , then 5s , 9s , 13s , .... , 1min , 1min and so on .

const delayFn = count =>  (count > 10 ? 60 : (4 * count + 1)) * 1000;

yield retry(3, delayFn, request, data);

maybe this could handle conditions #1760 , and user could add conditions in this passed function and if return value is false , break the retry iteration

https://github.com/redux-saga/redux-saga/blob/master/packages/core/src/internal/sagaHelpers/retry.js#L4

@sayjeyhi
Copy link
Author

@Andarist I think this could be done easily , if it sounds good to you , maybe I could made a PR

@carlosasj
Copy link

Hey @sayjeyhi
In case you still have to retry your saga, we recently released a package redux-saga-retry that may fit your needs 😃

@sayjeyhi
Copy link
Author

@carlosasj Good job

@neurosnap
Copy link
Member

Closing due to inactivity. If this is still an issue then please reply and I will reopen and try to help debug. Thanks!

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