-
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
Changes from 1 commit
f822740
f5c61e9
42222ba
03834a8
771f093
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,7 +300,7 @@ export type Config = { | |
detectNetwork: (callback: NetworkCallback) => void, | ||
effect: (effect: any, action: OfflineAction) => Promise<*>, | ||
retry: (action: OfflineAction, retries: number) => ?number, | ||
discard: (error: any, action: OfflineAction, retries: number) => boolean, | ||
discard: (error: any, action: OfflineAction, retries: number) => boolean|Promise<boolean>, | ||
defaultCommit: { type: string }, | ||
defaultRollback: { type: string }, | ||
persist: (store: any) => any, | ||
|
@@ -446,7 +446,14 @@ const config = { | |
} | ||
``` | ||
|
||
The method receives the Error returned by the effect reconciler, the action 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`. | ||
The method receives the Error returned by the effect reconciler, the action | ||
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 | ||
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 commentThe 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 commentThe 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. |
||
|
||
#### Change how network requests are retried | ||
|
||
|
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?