Last Updated: February 25, 2016
·
755
· malikbakt

requirejs + emberjs default structure

define 'app', [
  'app/controllers/application_controller',
  'app/views/application_view',
  'app/store'
], (AppController, AppView, Store) ->
  App = App.create(rootElement: "#app")
  App.referReadiness()
  App.ApplicationController = AppController
  App.ApplicationView = AppView
  App.Store = Store
  App.Route.map ->
    @route "home", path: "/"
  window.App = App

define 'app/views/home_view', ['app'], (App) ->
  App.HomeView = Ember.View.extend(...)

define 'app/controllers/home_controller', ['app'], (App) ->
  App.HomeController = Ember.Controller.extend(...)

define 'app/routes/home_route', ['app'], (App) ->
  App.HomeRoute = Ember.Route.extend(..)

define 'home', ['app/views/home_view', 'app/controllers/home_controller', 'app/routers/home_route'], (App) ->
  App.advanceReadiness()

require ['home'] # loads 'app', then 'home_*'