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

options object #46

@wilsonpage

Description

@wilsonpage

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions