text: var BaseModel = require("./BaseModel");
  var inherit = require("../utils/inherit");
  var commonEventNames = require("../core/commonEventNames");
  
  module.exports = ObservableList;
  
  /**
   * Observable list model. Sends notifications about it's state.
   * @constructor
   * @class ObservableList
   */
  function ObservableList(){
      BaseModel.call(this, [], null);
  }
  
  inherit(ObservableList, BaseModel);
  
  ObservableList.prototype.clear = function(){
      var data = this.__data;
      var i = data.length;
      while(i--){
          // Warn: item may be really removed from the data-list inside .remove() method!!
          this.remove(i);
      }
      // Just in case:
      this.__data.length = 0;
  };
  
  ObservableList.prototype.update = function(data){
      // Note: someone should ask to .clear() before calling this.. so don't forget!
      var i;
      if(Array.isArray(data)){
          for(i = 0; i < data.length; ++i){
              this.add(data[i]);
          }
      }
  
  };
  
  ObservableList.prototype.size = function(){
      return this.__data.length;
  };
  
  ObservableList.prototype.at = function(index){
      return index < this.size() ? this.__data[index] : null;
  };
  
  ObservableList.prototype.isExistId = function(id){
      return this.findIndexById(id) >= 0;
  };
  
  ObservableList.prototype.findIndexById = function(searchingId){
      var i;
      var result = -1;
      var currentElement;
      var id = parseInt(searchingId);
      for(i = 0; i < this.__data.length; ++i){
          currentElement = this.__data[i];
          if(currentElement.id === id){
              result = i;
              break;
          }
      }
      return result;
  };
  
  /**
   * Add item to the end of the list.
   * @param {*} item
   */
  ObservableList.prototype.add = function(item){
      // push to back and send actual index of the added item:
      this.observer.notify(commonEventNames.E_ITEM_ADDED, this.__data.push(item) - 1);
  };
  
  ObservableList.prototype.remove = function(index){
      if (index >= 0 && index < this.size()) {
          this.observer.notify(commonEventNames.E_ITEM_REMOVED, index);
          this.__data.splice(index, 1);
      }
  };
  