Add missing requestKey in example
When the example for getStatus is presented, it currently lacks the requestKey needed as part of the READ_RESOURCES_SUCCEEDED action. If that key is missing, that entry in the requests section will never changed status to SUCCEEDED, instead remaining in PENDING.
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?
- The typo you noticed with
frombeing typed asfom(good eye!) - The
requestshorthand to set both the key and name is deprecated, so it shouldn't appear in any of the examples. - A second typo..."deprecated" being spelled as "dreprecated" in the above link 🙈
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!