alexnm / re-ducks

An attempt to extend the original proposal for redux modular architecture: https://github.com/erikras/ducks-modular-redux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any ideas how this might work with sagas?

cafreeman opened this issue · comments

Hey there!

I read your Medium article and I think re-ducks is a really great idea! I've started working on implementing it in my own project and so far things are going really well, but I've hit one potential roadblock: sagas.

The Redux-Saga docs talk about composing all of your sagas like so:

// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield [
    helloSaga(),
    watchIncrementAsync()
  ]
}

This is similar to how you'd compose reducers, I suppose, except without the actual combineReducers equivalent.

I'm trying to figure out the best way to manage this same composition when I have sagas in individual ducks folders, and was wondering if you had any ideas or experience with this.

Thanks!

Hi,

One of the reasons I avoided redux-saga was the fact that I see it very coupled with the API implementation. I prefer redux-thunk because the operations you create are agnostic of the fact that you are fetching data from an api.

However, a similar structure would work with sagas I guess. If you create an example repo with sagas I'll be more than happy to link it from this one as an alternative example to redux-thunk.

As for the rootSaga question, operations and selectors are exported separately from each duck, so based on the same principle, you can import each saga separately into your store module (where you combine reducers and sagas).