-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Dynamic (sync) resolvable added in onEnter
hook not available in onSuccess
#3544
Comments
@christopherthielen this issue is quite a big blocker for us, could you please have a look at what's happening or maybe provide some suggestions for a work around? |
In fact, it's also happening in the |
You also reproduce this in the same hook, by defining the resolvable (sync) and calling the injector on the same transition right after; that shouldn't error right? const module = {foo: 'bar'};
transition.addResolvable({
token: 'module',
resolveFn: () => module,
});
transition.injector().get('module'); ==> |
When using |
This does look like a bug. The added resolve should be available in any (currently unentered) child states and in A few things to note:
const module = {foo: 'bar'};
transition.addResolvable({
token: 'module',
resolveFn: () => module,
data: module,
});
transition.injector().get('module');
const injector = transition.injector();
const foo = await injector.getAsync('foo');
console.log(foo);
const bar = await injector.getAsync('bar');
console.log(bar); const injector = transition.injector();
Promise.all([injector.getAsync('foo'), injector.getAsync('bar')])
.then(results => { console.log(results[0]); console.log(results[1]) })
You can't do this unless you explicitly provide the
By adding the resolvable in |
Thanks for looking into it and finding the bug, and also for pointing out This is probably why I ended up not using it, because I get the same error in my app when I change resolveFn to data. Unless I'm expected to use both? But that doesn't make sense to me. Not sure if this is related to the bug you fixed or not. |
Although it doesn't make much sense, use both. Maybe we can fix this in a future release. |
This is a:
My version of UI-Router is: 1.x
Bug Report
Current Behavior:
http://plnkr.co/edit/u0JKQCIabRCixHJLmBbB?p=preview
See console log. The app errors with:
Error: Resolvable async .get() not complete:"bar"
Expected Behavior:
For
bar
to be available in theonSuccess
hook, just likefoo
, because it's not async and there is no reason why it should not be available/complete.Expected behaviour is for it to work, just as it works in the
onBefore
hook.(FYI the reason I need it in the
onEnter
hook is because I'm relying on another global resolvable to create the new resolvable, which is only available in theonEnter
hook.)The text was updated successfully, but these errors were encountered: