"createBook"
. The resource slice in this situation might look like:Note: if you specify therequest
property on an action, then it will be used as both the key and the name. This API is from Redux Resource < 3.0. Although it will continue to work into the future, it is recommended that you explicitly setrequestKey
andrequestName
separately going forward.
createBook
fetchBook
fetchBooks
updateBook
deleteBook
favorites
, and the request is for a user searching through their favorites, then you may use searchFavorites
as the key.Note: Official React bindings for Redux Resource are in the works, and it will generate request keys for you. This section describes how you might go about using generated request keys in your application today.Keep in mind that it is okay to use manually created keys. Generated keys aren't necessarily better.
mapStateToProps
that fetches the request information automatically for you. Official React bindings for Redux Resource are being developed, and that is how it will work. It will use the library React Request under-the-hood.readStatus
) that will be updated to reflect the action that is modifying them. This alternative approach can be considered a convenience.getStatus
:getStatus
using this request key, you get the following object:createBook
for every creation request. This works really well if you can assume that a user is only able to send off one of these create requests at a time, which is a restriction that many applications adhere to.createFavorite
and deleteFavorite
for these two actions, rather than, say, using changeFavorites
for both. This makes your code more expressive, and also allows you to track both requests in the event that they are both in flight at the same time.deleteBook
, won't be enough to capture this information. You might choose to use a dynamic request key in this situation.