initializeObservers(layerGroups, controller) {
    // set initial state from QPs, grab init state from models
    const defaultVisibleLayerGroups = layerGroups.filterBy('visible').mapBy('id').sort().copy();
    const params = this.get('visibleLayerGroups');

    // set defaults through ember parachute
    controller.setDefaultQueryParamValue('layerGroupService.visibleLayerGroups', defaultVisibleLayerGroups);

    // check if the provided params are the default
    const isDefaultState = defaultVisibleLayerGroups
      .every(layerGroup => params.any(param => (param.id || param) === layerGroup));

    // check if QP isn't default and there are other params
    if (!isDefaultState && params.length) {
      // set initial state from query params when not default
      layerGroups.forEach((layerGroup) => {
        layerGroup.set('visible', params.any(param => (param.id || param) === layerGroup.id));

        if (layerGroup.get('layerVisibilityType') === 'singleton') {
          const { selected } = params.find(param => (param.id || param) === layerGroup.id) || {};

          if (selected) layerGroup.set('selected', selected);
        }
      });
    }

    this.addObserver('layerGroupRegistry.@each.selected', this, '_modelsToParams');
    this.addObserver('layerGroupRegistry.@each.visible', this, '_modelsToParams');
    this.addObserver('visibleLayerGroups.length', this, '_paramsToModels');
  }
/*
    initializeObservers
    public
    must occur _after_ the fully resolved _route_ model is set to the controller
    sets up initial state and observers for the controller

    signature is a model directly from the route
  */
initializeObservers
public
must occur _after_ the fully resolved _route_ model is set to the controller
sets up initial state and observers for the controller

signature is a model directly from the route
initializeObservers public must occur _after_ the fully resolved _route_ model is set to the controller sets up initial state and observers for the controller signature is a model directly from the route
initializeObservers(layerGroups, controller) {
    const defaultVisibleLayerGroups = layerGroups.filterBy('visible').mapBy('id').sort().copy();
    const params = this.get('visibleLayerGroups');
    controller.setDefaultQueryParamValue('layerGroupService.visibleLayerGroups', defaultVisibleLayerGroups);
    const isDefaultState = defaultVisibleLayerGroups
      .every(layerGroup => params.any(param => (param.id || param) === layerGroup));
    if (!isDefaultState && params.length) {
      layerGroups.forEach((layerGroup) => {
        layerGroup.set('visible', params.any(param => (param.id || param) === layerGroup.id));
        if (layerGroup.get('layerVisibilityType') === 'singleton') {
          const { selected } = params.find(param => (param.id || param) === layerGroup.id) || {};
          if (selected) layerGroup.set('selected', selected);
        }
      });
    }
    this.addObserver('layerGroupRegistry.@each.selected', this, '_modelsToParams');
    this.addObserver('layerGroupRegistry.@each.visible', this, '_modelsToParams');
    this.addObserver('visibleLayerGroups.length', this, '_paramsToModels');
  }
initializeObservers ( layerGroups , controller ) { const defaultVisibleLayerGroups = layerGroups . filterBy ( 'visible' ) . mapBy ( 'id' ) . sort ( ) . copy ( ) ; const params = this . get ( 'visibleLayerGroups' ) ; controller . setDefaultQueryParamValue ( 'layerGroupService.visibleLayerGroups' , defaultVisibleLayerGroups ) ; const isDefaultState = defaultVisibleLayerGroups . every ( layerGroup => params . any ( param => ( param . id || param ) === layerGroup ) ) ; if ( ! isDefaultState && params . length ) { layerGroups . forEach ( ( layerGroup ) => { layerGroup . set ( 'visible' , params . any ( param => ( param . id || param ) === layerGroup . id ) ) ; if ( layerGroup . get ( 'layerVisibilityType' ) === 'singleton' ) { const { selected } = params . find ( param => ( param . id || param ) === layerGroup . id ) || { } ; if ( selected ) layerGroup . set ( 'selected' , selected ) ; } } ) ; } this . addObserver ( 'layerGroupRegistry.@each.selected' , this , '_modelsToParams' ) ; this . addObserver ( 'layerGroupRegistry.@each.visible' , this , '_modelsToParams' ) ; this . addObserver ( 'visibleLayerGroups.length' , this , '_paramsToModels' ) ; }
initializeObservers
public
must occur _after_ the fully resolved _route_ model is set to the controller
sets up initial state and observers for the controller
initializeObservers public must occur _after_ the fully resolved _route_ model is set to the controller sets up initial state and observers for the controller
// set initial state from QPs, grab init state from models // set defaults through ember parachute // check if the provided params are the default // check if QP isn't default and there are other params // set initial state from query params when not default