import Ember from 'ember';
import layout from '../templates/components/mapbox-gl-source';

const {
  Component,
  computed,
  get,
  getProperties,
  guidFor
} = Ember;

export default Component.extend({
  layout,
  tagName: '',

  map: null,
  dataType: 'geojson',
  data: null,

  sourceId: computed({
    get() {
      return guidFor(this);
    },

    set(key, val) {
      return val;
    }
  }),

  init() {
    this._super(...arguments);

    const { sourceId, dataType, data } = getProperties(this, 'sourceId', 'dataType', 'data');


    this.map.addSource(sourceId, { type: dataType, data });
  },

  didUpdateAttrs() {
    this._super(...arguments);

    const { sourceId, data } = getProperties(this, 'sourceId', 'data');

    this.map.getSource(sourceId).setData(data);
  },

  willDestroy() {
    this._super(...arguments);

    this.map.removeSource(get(this, 'sourceId'));
  }
});

@@ -274,16 +274,34 @@
  null,%0A%0A
+  options: null,%0A%0A
   source
@@ -551,16 +551,169 @@
 data');%0A
+    let options = get(this, 'options') %7C%7C %7B%7D;%0A%0A    if (dataType) %7B%0A      options.type = dataType;%0A    %7D%0A%0A    if (data) %7B%0A      options.data = data;%0A    %7D
 %0A%0A    th
@@ -743,32 +743,15 @@
 Id, 
-%7B type: dataType, data %7D
+options
 );%0A 

Support any options mapbox source supports. Maintain backwards compatibility.