<commit_before>/**
 * Views are almost more convention than they are code — they don't 
 * determine anything about the visual part of your application. The general idea is to 
 * organize your interface into logical views, backed by models, each of 
 * which can be updated independently when the model changes, without 
 * having to redraw the entire page. 
 * 
 * Instead of digging into a JSON object, 
 * looking up an element in the DOM, and updating the HTML by hand, 
 * you can bind your view's render function to the model's "change" event — 
 * and now everywhere that model data is displayed in the UI, it is 
 * always immediately up to date.
 */
core.Class("core.mvc.View", 
{
  include : [core.property.MGeneric, core.event.MEvent],

  /**
   * @properties {Map} Properties to set initially
   */ 
  construct: function(properties) 
  {
    if (properties) {
      this.set(properties);
    }
  },

  properties : 
  {
    /** Instance of compiled template to produce final data / text for output e.g. HTML, JSON, ... */
    template : 
    {
      check: core.template.Template,
      nullable : true,
      apply : function() {
        this.render();
      }
    },

    /** The model/collection to render */
    model :
    {
      check : core.mvc.IModel,
      nullable : true,
      apply : function(value, old)
      {
        if (old) 
        {
          old.removeListener("change", this.render, this);

          if (old instanceof core.mvc.Collection)
          {
            old.removeListener("add", this.render, this);
            old.removeListener("remove", this.render, this);
          }
        }

        if (value) 
        {
          value.addListener("change", this.render, this);

          if (value instanceof core.mvc.Collection)
          {
            value.addListener("add", this.render, this);
            value.addListener("remove", this.render, this);
          }
        }
      }
    }
  },

  members :
  {
    /**
     * Renders the view using data from the attached model.
     */
    render : function() 
    {
      if (jasy.Env.isSet("debug")) {
        throw new Error("render() is abstract in core.mvc.View!");
      }<commit_msg>Fixed issue for listening for add/remove.<commit_after>/**
 * Views are almost more convention than they are code — they don't 
 * determine anything about the visual part of your application. The general idea is to 
 * organize your interface into logical views, backed by models, each of 
 * which can be updated independently when the model changes, without 
 * having to redraw the entire page. 
 * 
 * Instead of digging into a JSON object, 
 * looking up an element in the DOM, and updating the HTML by hand, 
 * you can bind your view's render function to the model's "change" event — 
 * and now everywhere that model data is displayed in the UI, it is 
 * always immediately up to date.
 */
core.Class("core.mvc.View", 
{
  include : [core.property.MGeneric, core.event.MEvent],

  /**
   * @properties {Map} Properties to set initially
   */ 
  construct: function(properties) 
  {
    if (properties) {
      this.set(properties);
    }
  },

  properties : 
  {
    /** Instance of compiled template to produce final data / text for output e.g. HTML, JSON, ... */
    template : 
    {
      check: core.template.Template,
      nullable : true,
      apply : function() {
        this.render();
      }
    },

    /** The model/collection to render */
    model :
    {
      check : core.mvc.IModel,
      nullable : true,
      apply : function(value, old)
      {
        if (old) 
        {
          old.removeListener("change", this.render, this);
          old.removeListener("add", this.render, this);
          old.removeListener("remove", this.render, this);
        }

        if (value) 
        {
          value.addListener("change", this.render, this);
          value.addListener("add", this.render, this);
          value.addListener("remove", this.render, this);
        }
      }
    }
  },

  members :
  {
    /**
     * Renders the view using data from the attached model.
     */
    render : function() 
    {
      if (jasy.Env.isSet("debug")) {
        throw new Error("render() is abstract in core.mvc.View!");
      }
{'fraction_non_alphanumeric': 0.11058823529411765, 'fraction_numerical': 0.0, 'mean_word_length': 2.1676602086438153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4513230', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1158, 'n_words': 409}