docs(javascript): add soc and logic#44
Conversation
* feat(docs): Create docusaurus and add some data to the FE Design page. * docs(testing): Fix images
| ## Where should the business logic reside? | ||
|
|
||
| TBD | ||
| Most of our application uses Redux, therefor this section will focus on where to locate logic using redux. |
There was a problem hiding this comment.
did you mean applications?
There was a problem hiding this comment.
Definitely, my bad. Thanks!
| In redux there are actions and reducers. A reducer is a pure function which returns the same value for a specific input and has no side effects. | ||
| We also use Selectors ([reselect](https://github.com/reduxjs/reselect)) to fetch data from the store. | ||
| In a react redux application, the data should be kept on the store. | ||
| We prefer putting as much logic in the reducer rather than the selector/action/event handler who started the operation. |
There was a problem hiding this comment.
shouldn't the business logic be on a redux middleware?
unless you dont want to talk about middlewares since its not part of redux, and you need to add it manually
There was a problem hiding this comment.
Well, I guess we can talk about it but I believe that redux-logic messes up the clear separation of concerns. A middleware is only a tool for us to achieve something, IMO it shouldn't contain real logic, but that's my opinion, lets discuss it :)
There was a problem hiding this comment.
Basically, I believe in what redux claim in their docs:
https://redux.js.org/style-guide/style-guide#put-as-much-logic-as-possible-in-reducers
There was a problem hiding this comment.
yeah I agree, if its logic related to the store than it should be in the reducer, I think I got confused with different kind of logic like async logic https://redux.js.org/style-guide/style-guide#use-thunks-for-async-logic
There was a problem hiding this comment.
Agreed, async logic should happen within a middleware, definitely.
einatnielsen
left a comment
There was a problem hiding this comment.
Looks great!!! added a few questions
No description provided.