Skip to content

Instantly share code, notes, and snippets.

@ArthurClemens
Last active March 19, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ArthurClemens/1b06a661c14bdb369f7c to your computer and use it in GitHub Desktop.
Save ArthurClemens/1b06a661c14bdb369f7c to your computer and use it in GitHub Desktop.
Mithril simple router wrapper
var router = function(component, name) {
return {
controller: function() {
// Do something generic like calling Google Analytics from here
console.log("router", name);
return new component.controller();
},
view: component.view
};
};
m.route(document.getElementById("page"), "/", {
"/": router(app, "app"),
"/project/:id": router(project, "project")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment