Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages of the ngrx/effects approach over redux-thunk?

Im currently planning a large scale Angular 6 application, and trying to find an approach for handling side effects that is best suitable to the team needs.

I realize that the most common way of doing it in the Ngrx ecosystem is by using the ngrx/effects library, and i was wondering what are the advantages of using it in comparison to thunk approach, which seems to be the most popular approach for React apps.

I get the idea of isolating all the side-effect causing logic in a single place, I always tend to isolate them under the Action Creators scope. Moving all the side effects logic to a different "abstraction layer" feels like it would add more overhead to writing a side-effect action, without considerable added value, as most of the "intense logic" actions are for handling side effects.

Is there any other reason to favor effects over thunks? Is there any fundamental difference between ngrx in Angular and the classic Redux for React, that makes ngrx/effect a better pick?

like image 514
Ben Ben Sasson Avatar asked Sep 26 '18 12:09

Ben Ben Sasson


2 Answers

The difference in the React/Redux stack maybe if you make use of sagas instead of thunks (https://github.com/redux-saga/redux-saga) as with a thunk you can generate a lot of side effects with one action but with saga you can generate many async action from a single action, and every action has its own scope so debug, code split, and separation of concerns is easier.

like image 188
Mosè Raguzzini Avatar answered Oct 13 '22 00:10

Mosè Raguzzini


ngrx/effects uses the power of rxjs (Observable) and is more for an angular environment.

like image 31
Gilles Avatar answered Oct 12 '22 23:10

Gilles