# bbOptionsProvider 
Allows deep merge for non primitive and non array properties.

Sample usage:

```javascript
angular.module('BB').provider('bbSomeOptions', function (bbOptionsProvider) {
    'ngInject';

    let options = {
        default_language: 'en',      
        available_languages: ['en']        
    };

    this.setOption = function (option, value) {
        options = bbOptionsProvider.setOption(options, option, value);
    };

    this.getOption = function (option) {
        return options[option];
    };

    this.$get = () => options;
});

```

## NOTES
 
  1.  Array properties are simply replaced therefore it's better to define objects if possible in order to benefit from deep merge feature.
 
      **DON'T**
      ```javascript
      let options = {
          groups: [
              {
                  name: 'group1',
                  prop1: 'val1',
                  prop2: { foo : 'bar'}
              },
              {
                  name: 'group1',
                  prop1: 'val1'         
              }
          ]
      }
      ```
      
      **DO:** 
      ```javascript
      let options = {
          groups: {
              group1: {            
                  prop1: 'val1',
                  prop2: { foo : 'bar'}
              },
              group2: {            
                  prop1: 'val1'
              }
          }
      }
      ``` 
 
  2. Provider validates keys.
   In bespoke project you can override only properties defined on SDK level.
   Validation is needed to make sure bespoke projects are using only allowed keys.
   If you need to create some sort of mapping, please use an array instead. 
   
      **DON'T**
      You won't be able to override such mapping in bespoke project.
      ```javascript
      let options = {
          associations: {
              'en_*': 'en',
              'fr_*': 'fr'
          }
      }
      ```
      
      **DO** 
      Arrays are simply replaced so such mapping is easy to override in bespoke project.
      ```javascript
      let options = {
          associations: [
              { 
                  key : 'en_*',  
                  value: 'en'
              },
              {   
                  key : 'fr_*',    
                  value: 'fr'
              }
          ]
      }
      ```