let corePersists,
    customPersists;

corePersists = simpla.behaviors.persists('api');
customPersists = {
  listeners: {
    'api.loaded': '_updateFromLoad'
  },

  observers: [
    '_uidChanged(uid)'
  ],

  _toObject() {
    return { text: this.value };
  },

  _fromObject(value) {
    if (!value || Object.keys(value).length === 0) {
      this.useDefault = true;
    } else {
      this.value = value.text || '';
    }
  },

  _equal(textA, textB) {
    return !!(textA && textB) &&
          textA.text === textB.text;
  },

  _updateFromLoad({ detail }) {
    this._fromObject(detail.value);
  },

  _uidChanged() {
    this.load()
  }
};

export default [ corePersists, customPersists ];

@@ -32,16 +32,51 @@
 sists;%0A%0A
+// Core perists behavior to extend%0A
 corePers
@@ -115,16 +115,93 @@
 ('api');
+%0A%0A// Custom persists behavior to extend core and implement abstract functions
 %0AcustomP
@@ -319,403 +319,1495 @@
 %0A%0A  
-_toObject() %7B%0A    return %7B text: this.value %7D;%0A  %7D,%0A%0A  _fromObject(value) %7B%0A    if (!value %7C%7C Object.keys(value).length === 0) %7B%0A      this.useDefault = true;%0A    %7D else %7B%0A      this.value = value.text %7C%7C '';%0A    %7D%0A  %7D,%0A%0A  _equal(textA, textB) %7B%0A    return !!(textA && textB) &&%0A          textA.text === textB.text;%0A  %7D,%0A%0A  _updateFromLoad(%7B detail %7D) %7B%0A    this._fromObject(detail.value);%0A  %7D,%0A
+/**%0A   * Converts current element to Object that can be stored in a JSON db%0A   * @return %7BObject%7D Object form of element%0A   */%0A  _toObject() %7B%0A    return %7B text: this.value %7D;%0A  %7D,%0A%0A  /**%0A   * Setup current value from given Object. Takes value.text and uses as value,%0A   * %09defaulting to ''. Sets useDefault to true if value is falsey or it has no%0A   * %09enumerable keys%0A   * @param  %7BObject%7D value Object to setup from%0A   * @return %7Bundefined%7D%0A   */%0A  _fromObject(value) %7B%0A    if (!value %7C%7C Object.keys(value).length === 0) %7B%0A      this.useDefault = true;%0A    %7D else %7B%0A      this.value = value.text %7C%7C '';%0A    %7D%0A  %7D,%0A%0A  /**%0A   * Check if both textA and textB are equal simpla-text elements.%0A   * Note: returns false if textA or textB are falsey, even if both are falsey%0A   * @param  %7BHTMLElement%7D textA  Text element to compare against%0A   * @param  %7BHTMLElement%7D textB  Text element to compare with%0A   * @return %7BBoolean%7D            True if textA and textB are equal in value, false%0A   *                                otherwise%0A   */%0A  _equal(textA, textB) %7B%0A    return !!(textA && textB) &&%0A          textA.text === textB.text;%0A  %7D,%0A%0A  /**%0A   * Update the current value from the load event%0A   * @param  %7BCustomEvent%7D event  Load event fired from sm-utility-connect%0A   * @return %7Bundefined%7D%0A   */%0A  _updateFromLoad(%7B detail %7D) %7B%0A    this._fromObject(detail.value);%0A  %7D,%0A%0A  /**%0A   * Observer for uid property. Re-loads the current data by calling this.load%0A   * @return %7Bundefined%7D%0A   */
 %0A  _

document persists behavior