Skip to content

Instantly share code, notes, and snippets.

@tridungpham
Created June 30, 2015 07:41
Show Gist options
  • Save tridungpham/150e819613ba1f70ec05 to your computer and use it in GitHub Desktop.
Save tridungpham/150e819613ba1f70ec05 to your computer and use it in GitHub Desktop.
var asyncModule = function(name) {
return {
controller: function() {
m.startComputation()
require([name], function(module) {
this.controller = new module.controller()
this.view = module.view
m.endComputation()
}.bind(this))
},
view: function(ctrl) {
return ctrl.view(ctrl.controller)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment