Created
September 20, 2016 05:23
-
-
Save anonymous/3244d9b8a48444c7eee4cf6a8c5acd83 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/lekutu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://unpkg.com/[email protected]/dist/redux.min.js"></script> | |
<script id="jsbin-javascript"> | |
//const createStore = require('redux').createStore | |
'use strict'; | |
var createStore = Redux.createStore; | |
function todos(state, action) { | |
if (state === undefined) state = []; | |
switch (action.type) { | |
case 'ADD_TODO': | |
return state.concat([action.text]); | |
default: | |
return state; | |
} | |
} | |
var store = createStore(todos, ['Use Redux']); | |
store.dispatch({ | |
type: 'ADD_TODO', | |
text: 'Read the docs' | |
}); | |
store.dispatch({ | |
type: 'ADD_TODO', | |
text: 'FUCK' | |
}); | |
console.log(store.getState()); | |
// [ 'Use Redux', 'Read the docs' ] | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//const createStore = require('redux').createStore | |
var createStore = Redux.createStore | |
function todos(state = [], action) { | |
switch (action.type) { | |
case 'ADD_TODO': | |
return state.concat([ action.text ]) | |
default: | |
return state | |
} | |
} | |
let store = createStore(todos, [ 'Use Redux' ], ) | |
store.dispatch({ | |
type: 'ADD_TODO', | |
text: 'Read the docs' | |
}) | |
store.dispatch({ | |
type: 'ADD_TODO', | |
text: 'FUCK' | |
}) | |
console.log(store.getState()) | |
// [ 'Use Redux', 'Read the docs' ]</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//const createStore = require('redux').createStore | |
'use strict'; | |
var createStore = Redux.createStore; | |
function todos(state, action) { | |
if (state === undefined) state = []; | |
switch (action.type) { | |
case 'ADD_TODO': | |
return state.concat([action.text]); | |
default: | |
return state; | |
} | |
} | |
var store = createStore(todos, ['Use Redux']); | |
store.dispatch({ | |
type: 'ADD_TODO', | |
text: 'Read the docs' | |
}); | |
store.dispatch({ | |
type: 'ADD_TODO', | |
text: 'FUCK' | |
}); | |
console.log(store.getState()); | |
// [ 'Use Redux', 'Read the docs' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment