BoilerplateMVC / Marionette-Require-Boilerplate

Marionette-Require-Boilerplate
MIT License
242 stars 61 forks source link

How do I add global configuration options to my App? #1

Closed polinom closed 11 years ago

polinom commented 11 years ago

As documentation of Marionette says: We have chans to pass options object to method start() of an Application. However, I cant find where do you call method start() so than I can pass my options to the application.

On the other hand, Marionette provides an event that is triggered before app initialization.

So I can just do follow:

myoptions = {'show_some_stuff': true}
MyApp.on("initialize:before", function(options){
  options.myoptions = myoptions
});

So my question is where start() method is triggered if it does, but if it does not triggers than what is the purpose of this method?

Reference: https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.application.md#adding-initializers

brettjonesdev commented 11 years ago

Hey, sorry - just saw your Issue had been opened.

App.start(options) gets called here, in MobileInit.js (and in DesktopInit.js, but options are not passed in that instance).

In this case, I am initializing my Application in 2 different files (MobileInit.js and DesktopInit.js), depending on whether device is mobile or desktop. Which context determines what options I am starting the Application with. It would certainly be possible to use the "initialize:before" event to set this as well, but I like the simplicity of passing in the options object.

This answer your question?