-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(javascript): add soc and logic #44
base: master
Are you sure you want to change the base?
Conversation
* feat(docs): Create docusaurus and add some data to the FE Design page. * docs(testing): Fix images
@@ -63,11 +63,26 @@ TBD | |||
|
|||
## 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean applications?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, async logic should happen within a middleware, definitely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!!! added a few questions
No description provided.