diegohaz / redux-saga-thunk

Dispatching an action handled by redux-saga returns promise
MIT License
221 stars 17 forks source link

Ability to add identifier (optional) to thunk #20

Closed braska closed 6 years ago

braska commented 6 years ago

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 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).

diegohaz commented 6 years ago

Hey, @braska. Sorry for the delayed response.

I agree that we can have something like that. Do you want to work on that?