Skip to content

Instantly share code, notes, and snippets.

@chrishan17
Created March 4, 2015 04:55
Show Gist options
  • Save chrishan17/857058449ace4783a7e4 to your computer and use it in GitHub Desktop.
Save chrishan17/857058449ace4783a7e4 to your computer and use it in GitHub Desktop.
mithril-file-separation
//app.model.js
var app = {};
app.PageList = function() {
return m.request({method: "GET", url: "pages.json"});
};
app.vm = {};
app.vm.init = function() {
this.pages = new app.PageList();
};
//app.controller.js
app.controller = function() {
app.vm.init();
};
//app.view.js
app.view = function() {
return app.vm.pages().map(function(page) {
return m("a", {href: page.url}, page.title);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment