redux-async-connect
redux-async-connect copied to clipboard
Support for nested components?
Hey,
I have two depth nested components, each has its own @asyncConnect,
I'd like in the @asyncConnect's outer component to refer data dispatched in the inner component but I don't see the dispatched data when invoking getState() in the reducers.
I didn't dig into the code flow of this component, but, should it be supported? (the methods are called in the right order),
Thanks.
@asaf Hey!
All fetchings are simultaneous ...
Usually it is correct behaviour.
So far I just can suggest you to do all fetching in one place: inner fetch in this case should be invoked in then
on outer fetch and provide proper result of promise
Yea well, at some cases it doesn't make sense, consider an example where a base component is responsible for fetching movies, while the top components may display them visually / show their availability, fetching the movies availability in the base component makes no sense as only one of the outer component requires them,
Well, you can close this issue for now if you want, we can see in the future whether people see this issue as a mandatory one or not =)
@asaf, thanks, i would rather mark it as feature request :)
I've recently had to deal with this particular scenario, mostly around resolving the context required by sub-components when making a API call. I've been lucky enough to be able to resolve this context in the router's onEnter
as the context is partially site-wide, but I see this as a decent feature request.
It's almost like redux-thunk
in declarative form (nested components with @asyncConnect decorators). Could get tricky though, not something I'd want to happen by default all the time.