├── .gitattributes ├── .gitignore ├── build └── browserify.js ├── client.js ├── index.html └── package.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | 30 | # ========================= 31 | # Operating System Files 32 | # ========================= 33 | 34 | # OSX 35 | # ========================= 36 | 37 | .DS_Store 38 | .AppleDouble 39 | .LSOverride 40 | 41 | # Thumbnails 42 | ._* 43 | 44 | # Files that might appear on external disk 45 | .Spotlight-V100 46 | .Trashes 47 | 48 | # Directories potentially created on remote AFP share 49 | .AppleDB 50 | .AppleDesktop 51 | Network Trash Folder 52 | Temporary Items 53 | .apdisk 54 | 55 | # Windows 56 | # ========================= 57 | 58 | # Windows image file caches 59 | Thumbs.db 60 | ehthumbs.db 61 | 62 | # Folder config file 63 | Desktop.ini 64 | 65 | # Recycle Bin used on file shares 66 | $RECYCLE.BIN/ 67 | 68 | # Windows Installer files 69 | *.cab 70 | *.msi 71 | *.msm 72 | *.msp 73 | 74 | # Windows shortcuts 75 | *.lnk 76 | -------------------------------------------------------------------------------- /build/browserify.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var build = require("browserify")(); 4 | 5 | build.add("./client.js"); 6 | 7 | build.bundle(function(err, buf) { 8 | if(err) { 9 | throw new Error(err); 10 | } 11 | 12 | require("fs").writeFileSync("./output/scripts.js", buf); 13 | }); 14 | -------------------------------------------------------------------------------- /client.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var m = require("mithril"), 4 | redux = require("redux"), 5 | 6 | store; 7 | 8 | store = redux.createStore(function(state, action) { 9 | if(!state) { 10 | return { 11 | text : "ZZZ" 12 | }; 13 | } 14 | 15 | switch(action.type) { 16 | case "TEXT_CHANGE": 17 | return Object.assign({}, state, { text : action.text }); 18 | 19 | default: 20 | return state; 21 | } 22 | }); 23 | 24 | store.subscribe(m.redraw.bind(m)); 25 | 26 | m.mount(document.body, { 27 | controller : function() { 28 | this.clickText = function(e) { 29 | e.preventDefault(); 30 | 31 | store.dispatch({ 32 | type : "TEXT_CHANGE", 33 | text : "It's currently: " + (new Date()).toTimeString() 34 | }); 35 | }; 36 | }, 37 | 38 | view : function(ctrl) { 39 | var state = store.getState(); 40 | 41 | return m("div", 42 | m("p", state.text), 43 | m("button", { onclick : ctrl.clickText }, "What time is it?") 44 | ); 45 | } 46 | }); 47 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Mithril/Redux Testing 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mithril-redux", 3 | "version": "1.0.0", 4 | "description": "Experimenting with mithril + redux", 5 | "scripts": { 6 | "build": "node build/browserify.js", 7 | "debug": "iron-node .", 8 | "start": "nodemon build/browserify.js --watch . --ignore output --ext js,css" 9 | }, 10 | "author": "Pat Cavit ", 11 | "license": "MIT", 12 | "repository": "tivac/mithril-redux", 13 | "dependencies": { 14 | "mithril": "^0.2.0", 15 | "redux": "^3.0.2" 16 | }, 17 | "devDependencies": { 18 | "browserify": "^11.0.1", 19 | "nodemon": "^1.4.1" 20 | }, 21 | "eslintConfig": { 22 | "env": { 23 | "node": true, 24 | "browser": true 25 | }, 26 | "rules": { 27 | "curly": 2, 28 | "dot-notation": 2, 29 | "eol-last": 0, 30 | "key-spacing": [ 31 | 2, 32 | { 33 | "beforeColon": true, 34 | "afterColon": true, 35 | "align": "colon" 36 | } 37 | ], 38 | "no-caller": 2, 39 | "no-constant-condition": 2, 40 | "no-dupe-args": 2, 41 | "no-dupe-keys": 2, 42 | "no-duplicate-case": 2, 43 | "no-empty": 2, 44 | "no-eval": 2, 45 | "no-ex-assign": 2, 46 | "no-extend-native": 2, 47 | "no-extra-parens": 0, 48 | "no-extra-semi": 2, 49 | "no-floating-decimal": 2, 50 | "no-func-assign": 2, 51 | "no-implied-eval": 2, 52 | "no-inner-declarations": 2, 53 | "no-mixed-requires": 0, 54 | "no-multi-spaces": [ 55 | 2, 56 | { 57 | "exceptions": { 58 | "VariableDeclarator": true 59 | } 60 | } 61 | ], 62 | "no-negated-in-lhs": 2, 63 | "no-new": 0, 64 | "no-obj-calls": 2, 65 | "no-sparse-arrays": 2, 66 | "no-trailing-spaces": 0, 67 | "no-underscore-dangle": 0, 68 | "no-unreachable": 2, 69 | "use-isnan": 2, 70 | "valid-typeof": 2 71 | } 72 | } 73 | } 74 | --------------------------------------------------------------------------------