Why use Redux-Observable over Redux-Saga?

前端 未结 7 1217
太阳男子
太阳男子 2020-12-22 15:22

I have used Redux-Saga. Code written with it is easy to reason so far, except JS generator function is messing up my head from time to time. From my understanding, Redux-Obs

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 15:38

    I use Redux-Observable over Redux-Saga because prefer to work with observables over generators. I use it with RXJS, which is a powerful library for working with streams of data. Think of it like lodash for async. In terms of any downsides, gotcha and compromises in choosing one over the other, take a look at this answer from Jay Phelps:

    redux-saga as a project has existed longer than redux-observable so that's certainly one major selling point. You'll find more documentation, examples, and likely are have a better community to get support from.

    The counter being that the operators and APIs you learn in redux-saga aren't nearly as transferable as learning RxJS, which is used all over the place. redux-observable is super super super simple internally, it's really just giving you a natural way for you to use RxJS. So if you know RxJS (or want to), it's an extremely natural fit.

    My advice at the moment for most people is that if you have to ask which one you should use, you probably should choose redux-saga.

提交回复
热议问题