redux-async-connect icon indicating copy to clipboard operation
redux-async-connect copied to clipboard

Support for nested components?

Open asaf opened this issue 8 years ago • 4 comments

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 avatar Feb 24 '16 13:02 asaf

@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

sars avatar Feb 24 '16 21:02 sars

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 avatar Feb 25 '16 09:02 asaf

@asaf, thanks, i would rather mark it as feature request :)

sars avatar Feb 29 '16 13:02 sars

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.

hongymagic avatar Apr 08 '16 01:04 hongymagic