171 karma · joined April 29, 2014
By decoupling the selection of state from the actual state structure (using relative selectors) + defining a public interface for your features (your app will basically consist of smaller apps - fractally) you can achieve what you're after.
[0] http://jaysoo.ca/2016/02/28/organizing-redux-application/
Regardless of the justifications Apple may have to continue on their current path, it personally (and very subjectively) makes me sad. They used to be a tent pole in my digital life, but now I feel we've lost touch with each other...
function createStore(reducer) {
let actions = [];
let subscribers = [];
return {
getState() {
return actions.reduce(reducer, undefined);
},
subscribe(subscriber) {
subscribers.push(subscriber);
},
dispatch(action) {
actions.push(action);
subscribers.forEach(subscriber => subscriber());
}
};
}
If you start out by digging into how Array.reduce works you're 90% there, which is where the name "Redux" comes from.Without the middleware support Redux pretty much boils down to this:
function createStore(reducer) {
let state = undefined;
let subscribers = [];
return {
getState() {
return state;
},
subscribe(subscriber) {
subscribers.push(subscriber);
},
dispatch(action) {
state = reducer(state, action);
subscribers.forEach(subscriber => subscriber());
}
};
}
The advantage of Redux will start to show itself first when your app grows larger and you start doing things like consuming many different views/derivatives of the same state (using selectors) spread across your application.Redux (core) doesn't actually solve the other big complexity culprit of big web applications though - asynchronous flow and side effects. For that you'll have to look into middlewares like redux-thunk or redux-saga, depending on your needs.
I'd suggest that instead of focusing on specific implementations such as Redux it's a good idea to take a look at those concepts + patterns like CQRS to get an understanding of why you'd want these things in the first place.
It's usually a good idea to feel the pain it alleviates before diving in at the deep end.
Take a step back and focus on JavaScript the language. Really learn how things work. Then take a step even further back. Learn more about data structures, about abstractions and how to think declaratively vs. imperatively. Rinse and repeat for the rest of the stack.
That way you'll have a solid foundation to build on top of. At some point you'll start to see patterns, and that all the "new" things are just incrementally improved materializations of patterns and concepts that have existed since way before the web was even thought of.
Spend most of your learning/experimenting time on fundamentals (timeless). Learn actual implementations and specifics when you need to, just in time. Avoid learning specifics (lib/fw) just in case.
Source: My own personal experience + the very insightful experience of teaching classes in JavaScript and React the last two years.
That way you'll have a solid foundation to build on top of. At some point you'll start to see patterns, and that all the "new" things are just incrementally improved materializations of patterns and concepts that have existed since way before the web was even thought of.
Spend most of your learning/experimenting time on fundamentals (timeless). Learn actual implementations and specifics when you need to, just in time. Avoid learning specifics (lib/fw) just in case.
Source: My own personal experience + the very insightful experience of teaching classes in JavaScript and React the last two years.
[0]: https://gist.github.com/eiriklv/a498112b3a73fc2b92975649924c...
[1]: https://gist.github.com/eiriklv/b6cc681447a0939365e1ba044fac...
Edit: wording
It took about 3 weeks to get over the withdrawal effect of sugar and what you might call detox (I was the biggest sugar junkie in the world - and had an attention span of 15 minutes tops). That stuff was rough. When the cravings stopped it took about a month or two before the benefits really started to show. After six months / a year it was second nature. Been doing it for 6+ years now. The benefits are so great that I would never consider going back.
It's important to note that you'll have to eat a fat-focused diet (paleo / keto). No sugar, low on carbs. Otherwise you won't get the benefit of not thinking about food, which is essential. After a certain amount of carbs your body will drop out of ketosis and you will get cravings - and that requires will, which drains resources. If you're successful at that your body will after a while get really good at leveraging fat as its main fuel, resulting in even keel energy.
I do this for mental clarity, focus and other health benefits, so I have no experience with the weight loss part. I've been 75kg since I was 17 (30 now) and my weight has never fluctuated more than 1-2kg, regardless of how much I eat. People would say that I eat a lot though. I also rarely exercise (at least hard).
Edit: typo
Edit: Another benefit is that you don't get the after lunch crash.
[1] - (see this for proof - https://hn.algolia.com/?query=fizzbuzz&sort=byPopularity&pre...)
Book - https://www.amazon.com/Good-They-Cant-Ignore-You/dp/14555091...
Talk - https://www.youtube.com/watch?v=IIMu1PGbG-0
Edit: Grammar / formatting
Edit: But he might be pointing to the testing of the actual HOCs/component decorating functions.
Thanks for all your hard work!
I get your point though. The real hardcore stuff still has to be done close to the metal. But it's pretty amazing how far you can get with just JavaScript today, with everything from server, browser, native and even hardware. Abstractions are powerful.