Skip to content

Commit

Permalink
redux-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
viviier committed Jul 7, 2018
1 parent 8a88e3c commit 268b018
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions redux-demo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
createStore } from "redux";

function reducer(state = 0, action) {

if (action.type === "inc") {

state += action.value;
}
return state;
}

const store = createStore(reducer);

store.subscribe(() => {

console.log(`store change: ${
store.getState()}`);
});

store.dispatch({
type: "inc", value: 1 });

12 changes: 12 additions & 0 deletions redux-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "redux-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}

0 comments on commit 268b018

Please sign in to comment.