Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

options object #46

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

options object #46

wilsonpage opened this issue Oct 2, 2013 · 1 comment

Comments

@wilsonpage
Copy link
Contributor

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;
}
@matthew-andrews
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants