Sha256: e3124ac1a91783d7c73e0a362b51531b15d8ef8c532b93f20573d5b57a99bd81

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

{ log, warn }= require('utils')

class Application extends Backbone.Model

  initialize: ->
    @initializers= []
    @set isReady:no

  addInitializer: (fn)->
    if @get 'isReady'
      fn.call this, @options
    else
      @initializers.push fn

  start: (options)->
    if @get 'isReady'
      # You can only 'start' the app once!
      warn "You can only start the application once!"
      this
    else
      log "Init!"
      @trigger 'app:init:before', app:this, options:options
      for fn in @initializers
        fn.call this, options
      @trigger 'app:init:after', app:this, options:options
      delete @initializers
      @options= options
      @set isReady:yes
    this

module.exports= new Application

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gumdrop-0.3.2 lib/gumdrop/template/backbone/app_src/app.js.coffee