You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got into this situation where my React component requires more than one prop.
One way to solve it was through adding two @resolve calls with two different callbacks.
This makes sense from a signature standpoint because the props aren't defined until the promise resolves. However, this is a problem because it means the resolver doesn't know if the props are pre-existing or not.
TBH, reducing duplicate in-flight requests should be handled via your request mechanism. Annoyingly, there are few implementations I found of this:
Because they're positional params, it's basically describing the required response signature should any of the props not exist.
Again, I feel this warrants mentioning...In my own side-projects using Redux (meh), co-locating data requirements via @resolve to their immediate components makes sense & works, but it's difficult to solve the duplicate request issue with Redux & in-flight requests.
If I figure this out, it'll probably solve it for several people.
re: Caching
It is definitely a solution, but it feels a little brittle. Mostly because it adds cache invalidation to the mix.
re: backwards compatible API
I hacked something together that basically just allows you to use a hash as opposed to an array. But I see the value of taking your approach to it.
I'd love to help out and try to come up with an implementation for this last suggestion 😄
My current solution basically hijacks resolve.js and checks if a complex has been returned from Resolver and then just deconstructs it.
Would resolve.js be the place to make this changes? Or does this sound more like something Resolver should handle?
Activity
ericclemmons commentedon Oct 30, 2015
Why not do:
That's what's happening internally:
💩 on me for not having this in the README or docs.
ericclemmons commentedon Oct 30, 2015
Misread it. You're right, there's not a way to return an object for multiple props from a single call.
I think this makes sense, especially for something like:
This makes sense from a signature standpoint because the props aren't defined until the promise resolves. However, this is a problem because it means the resolver doesn't know if the props are pre-existing or not.
TBH, reducing duplicate in-flight requests should be handled via your request mechanism. Annoyingly, there are few implementations I found of this:
Or my own:
ericclemmons commentedon Oct 30, 2015
Another backwards-compatible API would be something like:
Because they're positional params, it's basically describing the required response signature should any of the props not exist.
Again, I feel this warrants mentioning...In my own side-projects using Redux (meh), co-locating data requirements via
@resolveto their immediate components makes sense & works, but it's difficult to solve the duplicate request issue with Redux & in-flight requests.If I figure this out, it'll probably solve it for several people.
nettofarah commentedon Oct 30, 2015
This all makes sense, @ericclemmons.
re: Caching
It is definitely a solution, but it feels a little brittle. Mostly because it adds cache invalidation to the mix.
re: backwards compatible API
I hacked something together that basically just allows you to use a hash as opposed to an array. But I see the value of taking your approach to it.
I'd love to help out and try to come up with an implementation for this last suggestion 😄
My current solution basically hijacks
resolve.jsand checks if a complex has been returned fromResolverand then just deconstructs it.Would
resolve.jsbe the place to make this changes? Or does this sound more like somethingResolvershould handle?MatviiStelmakh commentedon Nov 7, 2018
small correction
:instead of,@resolve({
propA: function() { ... },
propB: function() { ... }
})