-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allow to use Promises on discard
function
#53
Conversation
Any update on this? I need this for my work... :-/ |
How would you use this? Do you have a sample |
My use case is to check when I get a
import defaults_discard from '@redux-offline/redux-offline/lib/defaults/discard'
let refresh
function setRefresh(_refresh)
{
refresh = _refresh
}
function discard(error, action, retries)
{
if(error.status === 401) return refresh().then(() => false)
return defaults_discard(error, action, retries)
} Maybe should I to update the |
I agree with @piranna, it would be awesome to have this functionality! |
I've added tests and documentation for returning a |
README.md
Outdated
being processed, and a number representing how many times the action has been | ||
retried. If the method returns `true`, the action will be discarded; `false`, | ||
and it will be retried. The full signature of the method is `(error: any, | ||
action: OfflineAction, retries: number) => boolean`. Alternatively, you can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would update the signature and leave it at that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you means?
README.md
Outdated
action: OfflineAction, retries: number) => boolean`. Alternatively, you can | ||
return a Promise object that resolve to a boolean, allowing you to detect when | ||
to discard asynchronously (for example, doing a request to a server to refresh a | ||
token and try again). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your editor appears to have inserted line breaks here. It doesn't affect the resulting document, but I'd prefer to leave them out, just for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added them myself, I'm used to 80 columns also on Markdown files. I don't like to scroll horizontally and I would change the full file instead to adjust it, but if you preffer to have it the old way I can be able to change it.
@piranna Thanks for the clarification. Other than some minor changes with the documentation, it looks good. @sorodrigo is getting ready for a release, and then we are looking to merge back into the original repo, so I'm not sure when we'll get to this. |
I think its a good addition. Also, there a |
I say we include this as a last addition before the next release |
The |
Yes I know haha it’s a style choice of the previous author. But I say if we are already updating this file why not change it. But its not THAT important. |
|
Ok, just make the last changes @wacii suggested and we can merge |
The one of the splitted lines on the |
I have removed the splitlines on |
Thanks! |
You are welcome! :-D Do you know when it could be published on npm? :-) |
This allow to return a Promise on the
discard
function so it's possible to decide asynchronously if a request should be discarded.