Last active
August 29, 2015 14:00
-
-
Save benbabics/11263035 to your computer and use it in GitHub Desktop.
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
define [ | |
'facade' | |
'BaseModule' | |
'./controllers/AppController' | |
'./controllers/NavigationController' | |
], | |
(facade, BaseModule, AppController, NavigationController) -> | |
class AppModule extends BaseModule | |
controller: | |
app: AppController | |
navigation: NavigationController | |
initialize: -> | |
# event listeners | |
@on 'require', @handleLoadedSubModule, @ | |
createController: (factory) -> | |
# get the controllers | |
App_Controller = factory 'app' | |
Nav_Controller = factory 'navigation' | |
# init the controllers | |
app_controller = new App_Controller() | |
nav_controller = new Nav_Controller() | |
# assign the primary controller that modules | |
# who are expecting this module to return an HTML fragment | |
@controller = app_controller | |
### Event Handlers ### | |
handleLoadedSubModule: (module_name) -> | |
@subscribe "#{module_name}:loaded", (Module) -> | |
new Module().start() | |
# register module | |
facade.register 'app', AppModule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment