-
Notifications
You must be signed in to change notification settings - Fork 3k
Rejected dependency resolution in a state hierarchy #2321
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
Comments
This isn't a bug. Resolves are loaded optimistically. If you want one to depend on another, inject the dependency. |
Thanks, I haven't thought to use injection to solve my issue... |
In the next major version, resolves will be able to have different policies you can configure to enable this. |
Just one more thought about that issue : the choice that have been made to load the resolves optmistically seems a bit akward to me. I think that the typical use-case would be to abort resolution on the first error, because there is a high probability that the resolved object is vital for the dependent views. For now, to emulate this behaviour, we have to inject the required dependencies in every single child state's resolves, which is a pain for what I consider a "typical" use. In contrary, if the first rejected resolve interrupts the resolution chain, people who want to ignore the error just have to append a
I think it makes more sense like that, but it's only my opinion ;) |
Things are parallelized as much as possible, because loading everything serially would be hugely inefficient.
Yup, except that promises have no generic cancellation mechanism. This is a known design issue and is being tracked in #2126. |
I agree on that point, my initial idea was more to parallelize on a per-branch basis and to serialize between branches :
Agree too, there is no such mecanism. By "abort resolution", I meant "let the parent promise failure natively take care of the abortion". A simple |
Again, (unless I'm misunderstanding you here) that would mean waiting until parent promises have resolved before resolving children, which is not an acceptable default behavior. |
I currently works on an app where a state sub-branch requires a request to be performed before everything else. If that request fails, the branch children shouldn't be accessed, especially the dependencies to be resolved.
For that purpose, I've appended a
resolve
dependency that performs the request on the root part of the branch (path.to.subroot
for all thepath.to.subroot.*
children).The bug : if the request fails, all the intermediary children
resolve
dependencies are executed without consideration.Here is a Plunkr to illustrate this bug. If you click on the link, you can see in the console the resolution of
foo
, it's rejection, the error caught via the$stateChangeError
hook, but also the second dependency (bar
) that shouldn't be resolved.The text was updated successfully, but these errors were encountered: