Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

`options` object #46

Open
wilsonpage opened this Issue Oct 2, 2013 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

wilsonpage commented Oct 2, 2013

As a module author I would like to be able to accept certain options that override default behaviour/characteristics. Currently this can be done manually by throwing keys onto the object passed into the constructor, and retrieving them inside the initialize callback.

var apple = new Apple({
  model: { foo: 'bar' },
  children: {},
  random: 'option'
});

later retrieved inside the module:

initialize: function(config) {
  var options = config.options || {};
  var random = options.random;
}

This is a little dodgy as this space should be reserved for FruitMachine configuration only. It is not clear to see what is an option specific to this module and what is FruitMachine configuration. I suggest the following:

var apple = new Apple({
  module: { foo: 'bar' },
  children: {},
  options: {
    random: 'option'
  }
});

later retrieved inside the module:

initialize: function(options, config) {
  var random = options.random;
}
Member

matthew-andrews commented Oct 3, 2013

This feels like it could be a mixin plugin helper...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment