<commit_before>(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['backbone', 'react'], factory);
    } else {
        // Browser globals
        root.amdWeb = factory(root.Backbone, root.React);
    }
}(this, function (Backbone, React) {
    "use strict";

    var getChangeOptions = function(component, model) {
        if (model instanceof Backbone.Collection) {
            return 'add remove reset sort';
        } else {
            return 'change';
        }
    };

    var subscribe = function(component, model, changeOptions) {
        if (!model)
            return;

        var throttledForceUpdate = _.debounce(function(){
            if (! component.isMounted()) {
                return;
            }
            (component.onModelChange || component.forceUpdate).call(component);
        }, 10);


        model.on(changeOptions, throttledForceUpdate, component);
    };<commit_msg>Only debounce collection updates because models are used for controlled components<commit_after>(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['backbone', 'react'], factory);
    } else {
        // Browser globals
        root.amdWeb = factory(root.Backbone, root.React);
    }
}(this, function (Backbone, React) {
    "use strict";

    var getChangeOptions = function(component, model) {
        if (model instanceof Backbone.Collection) {
            return 'add remove reset sort';
        } else {
            return 'change';
        }
    };

    var subscribe = function(component, model, changeOptions) {
        if (!model)
            return;

        var triggerRender = function() {
            if (component.isMounted())
                (component.onModelChange || component.forceUpdate).call(component);
        };

        if (model instanceof Backbone.Collection)
          triggerRender = _.debounce(triggerRerender, 0);
        //note: if we debounce models too we can no longer use model attributes
        //as properties to react controlled components due to https://github.com/facebook/react/issues/955

        model.on(changeOptions, triggerRender, component);
    };
{'fraction_non_alphanumeric': 0.11446046308431629, 'fraction_numerical': 0.002621231979030144, 'mean_word_length': 2.2667617689015693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '7550853', 'n_tokens_mistral': 599, 'n_tokens_neox': 574, 'n_words': 167}