Skip to content

define application region as function #3570

@taburetkin

Description

@taburetkin

define Application region in runtime

as i can see, there is no chance to do it right now, because user can pass to region property region class

if this improvement will be accepted: #3569 , then i can offer this kind of improvement for resolving this issue

Application

  constructor: function constructor(options) {
    this._setOptions(options);

    this.mergeOptions(options, ClassOptions$7);

    //this._initRegion(); //remove this line;

    MarionetteObject.prototype.constructor.apply(this, arguments);
  },
  _initRegion: function _initRegion() {
    var region = this.getOption('region', true); // old line: var region = this.region;

    if (!region) {
      return;
    }

    var defaults = {
      regionClass: this.regionClass
    };

    this._region = buildRegion(region, defaults);
  },
  getRegion: function getRegion() {
    if(!this._region) this._initRegion();
    return this._region;
  },


this will help define application as a function, and allow to initialize a region only if a region will be accessed, even after start of application

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions