You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to understand how the onBefore hooks act when synchronous. The documentation says:
If any hook modifies the transition synchronously (by throwing, returning false, or returning a TargetState), the remainder of the hooks are skipped.
To me, this means that if a hook returns a modification (throw, false, targetState), the remainder of the hooks will not run at all. But it seems that currently, the hooks will run, but their result is ignored. See plunkr (logs to console).
Have I misunderstood something? Is this as intended, or is it possible to change this so only the hooks that needs to run, will be run? Because currently, one onBefore hook can run multiple times unnecessarily. Lets say we have 3 onBefore hooks (A, B, C), each modifying the transition by returning new targetState:
Currently
A (new target) => B => C
A => B (new target) => C
A => B => C (new target)
Proposed
A (new target)
A => B (new target)
A => B => C (new target)
I am trying to do something similar to the above example with my Authorization hook, Organization hook (redirects if param is null) and a hook which needs to be async. I don't want the last async hook to run if not needed (i.e. Auth or Org hooks already handle it).
The text was updated successfully, but these errors were encountered:
But it seems that currently, the hooks will run, but their result is ignored. Have I misunderstood something? Is this as intended,
@csvn you haven't misunderstood, and no it's not as intended. Thanks for the bug report. If you are interested in fixing it, the relevant code is here:
Hello,
I am trying to understand how the
onBefore
hooks act when synchronous. The documentation says:To me, this means that if a hook returns a modification (throw, false, targetState), the remainder of the hooks will not run at all. But it seems that currently, the hooks will run, but their result is ignored. See plunkr (logs to console).
Have I misunderstood something? Is this as intended, or is it possible to change this so only the hooks that needs to run, will be run? Because currently, one
onBefore
hook can run multiple times unnecessarily. Lets say we have 3onBefore
hooks (A, B, C), each modifying the transition by returning newtargetState
:Currently
Proposed
I am trying to do something similar to the above example with my Authorization hook, Organization hook (redirects if param is
null
) and a hook which needs to be async. I don't want the last async hook to run if not needed (i.e. Auth or Org hooks already handle it).The text was updated successfully, but these errors were encountered: