Skip to content

Instantly share code, notes, and snippets.

@benbabics
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbabics/11263035 to your computer and use it in GitHub Desktop.
Save benbabics/11263035 to your computer and use it in GitHub Desktop.
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
define [
'BaseController'
],
(BaseController) ->
class NavigationController extends BaseController
initialize: (settings) ->
# sandbox event listeners
@sandbox.on 'controller:welcome', @handleControllerWelcome, @
###*
* Event Handlers
###
handleControllerWelcome: (greeting) ->
console?.log "#{greeting}, NavigationController!", @bootstrap
# exports
NavigationController
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment