Open obedcorrales opened 3 years ago
Thanks for taking the time to open this PR, @obedcorrales ! I believe this code example works as expected, but there are a few things here that should be updated, I think. I'll list those things at the end of this issue...but let's first look at why I think this example is working:
Here's a CodeSandbox showing how it works, with some comments.
tl;dr: the request
attribute sets both the key and the name of the request. So this request already has a request key: search
.
The arguments to getStatus
are not (state, requestKey)
, but it is instead (state, pathToStatus)
. So when we call it like this:
getStatus(state, "books.requests.search.status");
we're drilling into the state object, which looks something like:
Seeing the state object like this may make the second argument, books.requests.search.status
more clear. If you've ever used _.get()
from Lodash, it is very similar.
So what needs to be changed?
from
being typed as fom
(good eye!)request
shorthand to set both the key and name is deprecated, so it shouldn't appear in any of the examples.I can make a PR to fix these things, or if you wanted to take a stab at it that'd be cool, too. Just let me know. And thanks for opening this PR!
When the example for
getStatus
is presented, it currently lacks therequestKey
needed as part of the READ_RESOURCES_SUCCEEDED action. If that key is missing, that entry in therequests
section will never changed status to SUCCEEDED, instead remaining in PENDING.