Sometimes we use same action type to load different entities.
For example: you can dispatch LOAD_MY_ITEM to start fetching data from API. And you pass itemId to action payload.
In this case we have ability to use isPending selector in order to show spinner in UI. But if we load 2 items in the same time we can't distinguish which item loading currently in progress.
I suggest to introduce identifier that can be passed to sub-field of meta object of action. In this case we can check thunk state with using isPending selector in following way: isPending(state, LOAD_MY_ITEM, ownProps.itemId).
Case:
Sometimes we use same action type to load different entities.
For example: you can dispatch
LOAD_MY_ITEM
to start fetching data from API. And you passitemId
to action payload.In this case we have ability to use
isPending
selector in order to show spinner in UI. But if we load 2 items in the same time we can't distinguish which item loading currently in progress.I suggest to introduce identifier that can be passed to sub-field of
meta
object of action. In this case we can check thunk state with usingisPending
selector in following way:isPending(state, LOAD_MY_ITEM, ownProps.itemId)
.