Closed nabati closed 7 years ago
On a similar note, is there a canonical way of, from within a saga, matching an action "routed" for a specific reducer? For now I'm making use of something like
action.meta.__multiReducerKey == 'myKey'
, but this is just a temporary solution of course as it doesn't make sense of explicitly making use an (undocumented) implementation detail in this manner.
Basically, the put
function in Redux Saga is equivalent to dispatch
, so that you can do like this:
import { wrapDispatch } from 'multireducer'
function* foo() {
// blah blah
yield wrapDispatch(put, 'active')(barAction())
}
matching an action "routed" for a specific reducer?
Why do you want to route action to the specific reducer by yourself while mutlreducer can do that for you?
@yesmeck I'd prefer the syntax wrapAction()
to use with redux-saga or other situation, for example:
function* foo() {
yield put(wrapAction(barAction(), 'theKey'))
}
Sometimes we don't have to reuse the wrapped dispatch
, say we have only one action need to wrapped. I think wrapAction()
could be more elegant while meeting this situation.
Hope wrapAction()
could be exported again.
@zincli PR's welcome.
I'm wondering if there's a canonical way of
put()
ing actions using Redux Saga. Simply callingput()
with the created action won't work in conjunction with multireducer since we're not supplying a reducerKey.Looking at the previous releases, it seems like it was just recently that wrapAction was removed from the public api. Was there a reason for removing this? If not, I suggest exporting it once again, since it seems to allow a cleaner integration with Redux Saga than calling a wrapped dispatch.
What's your opinion?