Commit 4e79bbb1 authored by MrMan's avatar MrMan

Code split based on top level routes

parent c694a3c4
......@@ -6,9 +6,6 @@ System.register([
"./components/main-layout.js",
"./components/with-route-triggered-loader.js",
"./components/inbox-mail.js",
"./components/starred-mail.js",
"./components/draft-mail.js",
"./components/important-mail.js",
], function(exportModule, moduleCtx) {
return {
execute: function() {
......@@ -17,18 +14,12 @@ System.register([
moduleCtx.import("./components/main-layout.js"),
moduleCtx.import("./components/with-route-triggered-loader.js"),
moduleCtx.import("./components/inbox-mail.js"),
moduleCtx.import("./components/starred-mail.js"),
moduleCtx.import("./components/draft-mail.js"),
moduleCtx.import("./components/important-mail.js"),
])
.then(function(deps) {
var EmailSvc = deps.shift().service;
var MainLayout = deps.shift().component;
var WithRouteTriggeredLoader = deps.shift().component;
var InboxMail = deps.shift().component;
var StarredMail = deps.shift().component;
var DraftMail = deps.shift().component;
var ImportantMail = deps.shift().component;
// Set up the app
m.route(document.body, "/inbox", {
......@@ -46,37 +37,58 @@ System.register([
"/starred": {
render: function() {
return m(MainLayout, m(WithRouteTriggeredLoader, {
title: "Loading starred emails...",
// This function provides the data
loadFn: function() { return EmailSvc.getEmails(); },
// This function provides the component to WithRouteTriggeredLoader
childFn: function(data) { return m(StarredMail, {emails: data}); }
}));
// Load starred mail *when we need it*
return moduleCtx
.import("./components/starred-mail.js")
.then(function(StarredMailModule) {
var StarredMail = StarredMailModule.component;
return m(MainLayout, m(WithRouteTriggeredLoader, {
title: "Loading starred emails...",
// This function provides the data
loadFn: function() { return EmailSvc.getEmails(); },
// This function provides the component to WithRouteTriggeredLoader
childFn: function(data) { return m(StarredMail, {emails: data}); }
}));
});
}
},
"/draft": {
render: function() {
return m(MainLayout, m(WithRouteTriggeredLoader, {
title: "Loading draft emails...",
// This function provides the data
loadFn: function() { return EmailSvc.getEmails(); },
// This function provides the component to WithRouteTriggeredLoader
childFn: function(data) { return m(DraftMail, {emails: data}); }
}));
return moduleCtx
.import("./components/draft-mail.js")
.then(function(DraftMailModule) {
DraftMail = DraftMailModule.component;
return m(MainLayout, m(WithRouteTriggeredLoader, {
title: "Loading draft emails...",
// This function provides the data
loadFn: function() { return EmailSvc.getEmails(); },
// This function provides the component to WithRouteTriggeredLoader
childFn: function(data) { return m(DraftMail, {emails: data}); }
}));
});
}
},
"/important": {
render: function() {
return m(MainLayout, m(WithRouteTriggeredLoader, {
title: "Loading important emails...",
// This function provides the data
loadFn: function() { return EmailSvc.getEmails(); },
// This function provides the component to WithRouteTriggeredLoader
childFn: function(data) { return m(ImportantMail, {emails: data}); }
}));
return moduleCtx
.import("./components/important-mail.js")
.then(function(ImportantMailModule) {
var ImportantMail = ImportantMailModule.component;
return m(MainLayout, m(WithRouteTriggeredLoader, {
title: "Loading important emails...",
// This function provides the data
loadFn: function() { return EmailSvc.getEmails(); },
// This function provides the component to WithRouteTriggeredLoader
childFn: function(data) { return m(ImportantMail, {emails: data}); }
}));
});
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment