Open jarvisaoieong opened 8 years ago
Thanks for submitting your solution @jarvisaoieong!
I quite like it but in my opinion 'action.action.type' makes the root/parent reducer know too much about the inner implementation of randomGifPairOfPair (e.g. the exact nesting level of the inner randomGif components).
I can imagine multiple ways of solving that:
What do you think?
@jarvisaoieong I really like your approach and it's very similar to what I did with redux-elm
Just one nitpick but the code does not meet this requirement:
It should also be easy to move the position of components. For example imagine the button is top left of your app, and the business now wants it inside a popup, bottom right: this move of component in the tree should rather be easy to make (ie without having to modify all parent components, for example).
Since you need to explicitly define action nesting
This is live demo: http://jarvisaoieong.github.io/redux-architecture-challenge/ This is my original repo: https://github.com/jarvisaoieong/redux-architecture-challenge
The most valuable part of my solution is in mainReducer
Imagine, the requirement changed. Now we only want to count the NEW_GIF action happened in randomGifPair and randomGifPairOfPair, except in randomGif and randomGifList.
With high order reducer function, it is very easy to implement. We just need to call reducer enhancer to our target reducer. That's all.
IMO, modern frontend architecture is based on FP.
What we need to do is Inventing on Principle
My principle:
Apply these basis functional programming technique, we don't need any extra concept.