Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

MatanBobi
Copy link
Contributor

No description provided.

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean applications?

Copy link
Contributor Author

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.
Copy link
Contributor

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

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

@MatanBobi MatanBobi Oct 12, 2020

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.

Copy link
Contributor

@einatnielsen einatnielsen left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants