-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Add counter-vanilla example #1289
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
Conversation
</head> | ||
<body> | ||
<div> | ||
<p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't written HTML in ages. It looks so much like JSX! Oh wait
render() | ||
store.subscribe(render) | ||
|
||
document.getElementById('increment') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminds me of a CycleJS app <3
<html> | ||
<head> | ||
<title>Redux basic example</title> | ||
<script src="https://npmcdn.com/redux@latest/dist/redux.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost had a JS fatigue here but thank goodness @mjackson made npmcdn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh but you aren't using bower and webpack here, how can this possibly work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use brcdn.org for any packages that don't include umd builds in npm :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I wonder how function render() {
var state = store.getState();
rerenderWidget1(state.widget1);
rerenderWidget2(state.widget2);
rerenderWidget3(state.widget3);
rerenderWidget4(state.widget4);
rerenderWidget5(state.widget5);
} Every time user performs an action, state updates and all widgets are rerendered (expensive!). Is there any way to rerender only particular widget? I guess we can keep previous state and check for changes: function render() {
var state = store.getState();
if (areNotEqual(prevState.widget1, state.widget1)) {
rerenderWidget1(state.widget1);
}
// ....
} But I'm not sure if this is a good solution or not. If application is really big, then it would be way a lot of checks. |
We don't actually advise you to use Redux without a performant view layer like React, Deku, Angular 2, virtual-dom, etc. The point of this example is to show that Redux is not coupled to either and doesn't require build tools, but sure you'll need some abstraction. To clarify though, you don't need something like |
Good point. Thanks |
The new Counter Vanilla example is aimed to dispel the myth that Redux requires Webpack, React, hot reloading, sagas, action creators, constants, Babel, npm, CSS modules, decorators, fluent Latin, an Egghead subscription, a PhD, or an Exceeds Expectations O.W.L. level.
Nope, it's just HTML, some artisanal
<script>
tags, and plain old DOM manipulation. Enjoy!