-
Notifications
You must be signed in to change notification settings - Fork 9
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
Improved onError handling #7
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
233f569
Will now always abort when an error happens
dlmr c8af93b
Updated the example servers to log the error that might happen
dlmr 6830acf
Now runs defer and blocking separately in parallel and better onError
dlmr 8851f4a
Updated simple example with new paths that fail on the client
dlmr 0c56e39
Improved the example for onError to only take action on certain reasons
dlmr d962204
Renamed RedialContextContainer to RedialContainer and added displayName
dlmr 1ea26b9
Added onCompleted when both blocking and deferred has completed, "all"
dlmr 4594f0d
Changed so onCompleted for blocking will always be invoked before defer
dlmr 0042d64
We now only run defer onError if blocking completed successfully
dlmr 407dd04
Made sure that aborting from an error only cancels the corresponding req
dlmr 5c6f4a4
Renamed blocking => beforeTransition and defer => afterTransition
dlmr 6cb8d89
Made sure we have consistent behaviour when running in parallel and not
dlmr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { Component } from 'react'; | ||
import { provideHooks } from 'redial'; | ||
|
||
@provideHooks({ | ||
defer: ({ setProps, getProps }) => new Promise((resolve) => { | ||
const { color } = getProps(); | ||
if(!color) { | ||
if (typeof window === 'object') { | ||
throw new Error('Defer: Demo error on client side only'); | ||
} | ||
setTimeout(() => { | ||
const getValue = () => Math.round(Math.random() * 255); | ||
setProps({color: `rgb(${getValue()}, ${getValue()}, ${getValue()})`}); | ||
resolve(); | ||
}, 1000); | ||
} else { | ||
resolve(); | ||
} | ||
}) | ||
}) | ||
export default class Fetch extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<h1 style={{ color: this.props.color }}>Client will get error on blocking</h1> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { Component } from 'react'; | ||
import { provideHooks } from 'redial'; | ||
|
||
@provideHooks({ | ||
fetch: ({ setProps, getProps }) => new Promise((resolve) => { | ||
const { color } = getProps(); | ||
if(!color) { | ||
if (typeof window === 'object') { | ||
throw new Error('Fetch: Demo error on client side only'); | ||
} | ||
setTimeout(() => { | ||
const getValue = () => Math.round(Math.random() * 255); | ||
setProps({color: `rgb(${getValue()}, ${getValue()}, ${getValue()})`}); | ||
resolve(); | ||
}, 1000); | ||
} else { | ||
resolve(); | ||
} | ||
}) | ||
}) | ||
export default class Fetch extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<h1 style={{ color: this.props.color }}>Client will get error on blocking</h1> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Needed?
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.
If we want the component to not be called something like
t
in React devtools.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.
ok