Comments (3)
Keeping your data flat makes sense for trivial example projects, but not for bigger projects. It seems unreasonable to have a reducer file for every variable in your application state. It's more practical to group related data, not only because mental model of your application easier to reason about, but because there are actions that might update multiple parts of your reducer.
For example, you might keep username
and userId
in your user
reducer and on a logout
action you might set both of those to null
. Keeping a separate reducer for both username
and userId
would result in you writing more code. Also, what are you really sacrificing here?
const { username, userId } = this.props.user
vs.
const { username, userId } = this.props
;
I think the argument of keeping your data flat, refers to the state object in the reducer. Which I generally agree with. IE, in regards to player
, means keeping this object flat:
const initialState = {
currentSongIndex: null,
currentTime: 0,
isPlaying: false,
selectedPlaylists: [],
};
from sound-redux.
To answer your question about the use of server data as entities
. That is definitely not a hard and fast rule. You should place objects in entities
if they are things that might appear in more than one place.
For example, the same song might appear in multiple playlists or even a search query. A user might be the author of multiple songs or make multiple comments.
An example of server data that wouldn't belong in the entities object, would be a chat message. If you had a chatroom application, you wouldn't expect to see the same chat message appear in multiple rooms. (You could certainly see the same text, but the messages id
would always be unique). I might be inclined to keep the messages as an array of objects.
from sound-redux.
Great this write up makes sense. I guess I just need more practice with it :)
Thanks again. Your repo is super helpful to everyone. Haha must be fun to code in react/redux on a music player you wrote yourself in react/redux.
from sound-redux.
Related Issues (20)
- [Bug] Not being able to fetch more songs HOT 2
- [Improvements] Fadein images
- Uncaught ReferenceError: webpackJsonp is not defined at main.js:1
- How to set sound-redux folder in GoPath HOT 1
- ERR_EMPTY_RESPONSE HOT 5
- Create telegram group and include it in .md file for discussion.
- getPlaylist initialized in UserSelectors.js:7 and SongSelectors.js:27 HOT 1
- Player of sound-redux not work in localhost (http://localhost:8080) HOT 1
- Smoother stickyOnScroll...?
- Uncaught (in promise) DOMException: Failed to load because no supported source was found. HOT 1
- Songs won't load HOT 2
- Songs won't load
- Doing a clone in Elm HOT 1
- error when i try to sign into soundcloud HOT 1
- Music List is not loading on Production HOT 3
- delete me
- using 'Component' instead of 'PureComponent'
- npm run start is not working HOT 3
- Using deprecated lifecycle methods HOT 1
- npm install and npm run start is not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sound-redux.