Last active
March 19, 2016 20:24
-
-
Save ArthurClemens/1b06a661c14bdb369f7c to your computer and use it in GitHub Desktop.
Mithril simple router wrapper
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
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