Last active
May 14, 2016 16:25
-
-
Save leeoniya/994acbbb4f1e9ede305df0f93f7008d0 to your computer and use it in GitHub Desktop.
This file contains 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
function Dashboard (vm) { | |
return function () { | |
return ['#dash', | |
[Chart, { interval: 2500, line_width: 3 }, 0], | |
[Chart, { interval: 5000, line_width: 8 }, 1], | |
[Chart, { interval: 60000, line_width: 2 }, 2], | |
[Chart, { interval: 20000, line_width: 1 }, 3], | |
] | |
} | |
} | |
function Chart (vm) { | |
function didInsert (node) { | |
console.log("node.el:", node.el); | |
} | |
return function () { | |
return ['canvas.chart', {_hooks: { didInsert: didInsert }}] | |
} | |
} | |
function Router (router) { | |
var curView = [Dashboard]; | |
function App (vm) { | |
return function () { | |
return ['#app', curView || 'Loading...']; | |
} | |
} | |
var vm = domvm.view(App) | |
router.config({ | |
init: function () { | |
vm.mount(document.body) | |
} | |
}) | |
return { | |
dashboard: { | |
path: '/', | |
onenter: function () { | |
console.log('onenter / redraw') | |
curView = [Dashboard] | |
vm.redraw() | |
} | |
} | |
} | |
} | |
var router = domvm.route(Router) | |
setTimeout(function() { | |
router.refresh() | |
}, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment