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

Use Redux to store client application state #4

Merged
merged 5 commits into from
Sep 20, 2020
Merged

Use Redux to store client application state #4

merged 5 commits into from
Sep 20, 2020

Conversation

mrgnr
Copy link
Member

@mrgnr mrgnr commented Sep 19, 2020

Redux provides a centralized store for application state. Previously, state that needed to be shared by multiple components was "lifted up", but this results in passing lots of data and callback functions down through the component hierarchy via props. Keeping state in a central location alleviates this problem, which would probably become increasingly worse as more components are added to the UI.

In addition to the core Redux package, the following dependencies have also been added:

  • React Redux -- makes it easier to integrate Redux into our React components, namely via the connect function which allows us to pass Redux state and actions via props
  • Redux Toolkit -- organizes Redux code into slices and reduces boilerplate for action creators
  • Redux Saga -- middleware that handles asynchronous calls and side-effects. We treat interaction with the RTC Manager as a side-effect from the perspective of Redux, so this code runs in a saga.

Redux allows us to centralize global state. This should turn out better
than having global state stored in the top-level App component, since
each component can access the state that it needs to directly rather
than passing props and callback functions through the component
hierarchy.

Updating the manager (e.g. setting a username) is considered a
side-effect, so Redux-Saga will be used as the point of contact between
the manager and the rest of the front end.
users, chatMessages, feeds, and connections are now stored in redux
rather than the top-level App component.
Redux Toolkit reduces boilerplate (especially writing actions and action
creators) and makes organization a bit cleaner.
Also bump development version.
@mrgnr mrgnr marked this pull request as ready for review September 20, 2020 12:18
@mrgnr mrgnr merged commit 4b24506 into master Sep 20, 2020
@mrgnr mrgnr added the enhancement New feature or request label Oct 10, 2020
@mrgnr mrgnr deleted the redux branch December 18, 2020 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant