Using error event and error substates together


#1

In a route’s model hook, sometimes promises may fail. In this cases:

  1. if the user are transitioning from one route to another: abort transition so that stay at the previous route and show an error popup.
  2. if the user is directly opening that route from an outside link: show the error substate.

How can I handle both cases? In the error hook, is there a way to understand whether the previous route is transitioning from somewhere else or not?


#2

I found that transition object has a property called sequence. This is always 0 if the user directly goes to that route.

I’ll use it, but I don’t see any documentation about it.

A typical error handler in application route will be like this:

error(reason, transition){
  if(transition.sequence ===0){
    return true;
  }
  showErrorPopup(reason);
  transition.abort();
}

Can someone say whether it is ok or not to use sequence property?