neilff / redux-ui-router

ngRedux bindings for Angular UI Router
MIT License
143 stars 48 forks source link

State params are not accessible through redux in resolve blocks #92

Closed mattdarveniza closed 3 years ago

mattdarveniza commented 7 years ago

I've got the fairly common pattern of calling some data loading actions in the resolve block of my routes, however these actions rely on the ui-router state parameters already being defined.

It seems that the router actions that set the state params are dispatched after the resolve block. Is there a way to access those parameters in the resolve outside of injecting $stateParams in directly?

kaidjohnson commented 7 years ago

I believe this is a timing issue from when the store gets updated. Currently, the store is updated onFinish, but resolve happens during the onEnter phase, from what I can tell. When I switch the onFinish hook to onEnter, then I am able to access the correct currentParams in my resolve blocks.

Is there a reason why the store gets stored onFinish rather than earlier, such as during onEnter?

hally9k commented 7 years ago

@kaidjohnson Not off the top of my head. I would be keen to see a PR to fix this if anyone has a spare moment. I'll try and have a little look.