Skip to content

Instantly share code, notes, and snippets.

@fritz-gerneth
Last active December 16, 2015 04:19
Show Gist options
  • Save fritz-gerneth/5376032 to your computer and use it in GitHub Desktop.
Save fritz-gerneth/5376032 to your computer and use it in GitHub Desktop.
(function (InnoAccel, _) {
"use strict";
InnoAccel.Application = function (instances) {
var self = this,
services = instances || {},
registeredModules = [];
if (!services.request) {
services.request = Meteor.Location;
}
if (!services.router) {
services.router = new InnoAccel.Router.Reactive(
new InnoAccel.Router.SimpleRouteList([]),
services.request.getPath
);
}
if (!services.dispatcher) {
services.dispatcher = new InnoAccel.Controller.Dispatcher(services.router.match, []);
}
if (!services.view) {
services.view = new InnoAccel.Controller.View();
}
this.getRequest = function () {
return services.request;
};
this.getDispatcher = function () {
return services.dispatcher;
};
this.getRouter = function () {
return services.router;
};
this.getView = function () {
return services.view;
};
this.registerModule = function (module) {
registeredModules.push(module);
return self;
};
this.registerModules = function (modules) {
_.each(modules, function (module) {
registeredModules.push(module);
});
return self;
};
this.bootstrap = function () {
_.each(registeredModules, function (module) {
module.bootstrap(self);
});
return self;
};
this.start = function () {
_.each(registeredModules, function (module) {
module.start(self);
});
this.getDispatcher().start();
return self;
};
};
}(InnoAccel, _));
(function (InnoAccel, Meteor) {
"use strict";
var application = new InnoAccel.Application();
application.registerModules([
new InnoAccel.Project.Module(),
new InnoAccel.Account.Module()
])
.bootstrap();
Meteor.startup(function () {
application.start();
});
}(InnoAccel, Meteor))
(function (Project) {
"use strict";
Project.Module = function () {
this.bootstrap = function (application) {
application.getRouter().addRoute(
new InnoAccel.Router.Segment('/project/:id', {module: 'project', action: 'index'})
);
application.getDispatcher().addController(
new InnoAccel.Project.Controller.Dashboard(application.getView())
);
};
this.start = function () {};
};
}(InnoAccel.Project));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment