Giter Site home page Giter Site logo

Comments (4)

PAkerstrand avatar PAkerstrand commented on July 25, 2024

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:

  1. onError is at most invoked once per route transition.
  2. afterTransition will only resolve if beforeTransition succeeds, else it will also reject.

Thoughts?

from react-router-redial.

dlmr avatar dlmr commented on July 25, 2024

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.

  1. 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.

  1. 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.

PAkerstrand avatar PAkerstrand commented on July 25, 2024

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.

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"?

  1. 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.

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,
  ...
});
  1. 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?

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.

dlmr avatar dlmr commented on July 25, 2024

@PAkerstrand This makes sense, will do the needed adjustments for this in #7

from react-router-redial.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.