Comments (4)
I ❤️ the before-/afterTransition
names. Not too fond of parallel
-rename though. In my mind it can be confused with the route transition not being blocked after all. What about runTransitionHooksInParallel
? Also, I'd like to enforce that:
onError
is at most invoked once per route transition.afterTransition
will only resolve ifbeforeTransition
succeeds, else it will also reject.
Thoughts?
from react-router-redial.
In my mind it can be confused with the route transition not being blocked after all.
The route transition will still be blocked, it's just that we will not wait util all the beforeTransition
hooks have been completed before firing of the hooks for afterTransition
. So the actual effect that happens when settings parallel
to true is that we start the afterTransition
hooks together with beforeTransition
.
- onError is at most invoked once per route transition.
The problem with this is that if we are in parallel
mode and a afterTransition
hook fails, should we just handle that as a general error? The idea with having onError
called twice is that we might want to handle an error from a beforeTransition
hook in another way than an error for afterTransition
since we might still want to make our transition.
- afterTransition will only resolve if beforeTransition succeeds, else it will also reject.
Do you mean that we should always wait with firing any events util after beforeTransition
is completed, even if afterTransition
fails/completes before beforeTransition
when in parallel
mode?
from react-router-redial.
In my mind it can be confused with the route transition not being blocked after all.
The route transition will still be blocked, it's just that we will not wait util all the
beforeTransition
hooks have been completed before firing of the hooks forafterTransition
. So the actual effect that happens when settingsparallel
to true is that we start theafterTransition
hooks together withbeforeTransition
.
I understand this, but I think the suggested rename makes this distinction less clear. If we runAfterTransitionImmediately
"would that mean that no blocking takes place"?
- onError is at most invoked once per route transition.
The problem with this is that if we are in
parallel
mode and aafterTransition
hook fails, should we just handle that as a general error? The idea with havingonError
called twice is that we might want to handle an error from abeforeTransition
hook in another way than an error forafterTransition
since we might still want to make our transition.
My idea is that if/when onError
is resolved, the parameter passed to onError
contains all info necessary to find which hooks failed, whether the transition took place etc. Something along the lines of:
onError({
runTransitionHooksInParallel: true,
beforeTransitionSuccess: true,
afterTransitionSuccess: false,
failures: [{
component: function Dashboard() {},
beforeTransition: [],
afterTransition: ['trackStatistics', 'afterTransitionCompleted'],
}],
router,
location,
...
});
- afterTransition will only resolve if beforeTransition succeeds, else it will also reject.
Do you mean that we should always wait with firing any events util after
beforeTransition
is completed, even ifafterTransition
fails/completes beforebeforeTransition
when inparallel
mode?
Yes, I'd like to, in some way, orchestrate the error notification in order to gather as much data as possible about the errors. And I don't think it's unreasonable to assume that in order for afterTransition
to succeed, beforeTransition
has to succeed before. This does not imply that we can't invoke the hooks in parallel, but rather that afterTransition
has a dependency on the success of beforeTransition
in order to make sense.
from react-router-redial.
@PAkerstrand This makes sense, will do the needed adjustments for this in #7
from react-router-redial.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-router-redial.