<commit_before>const createPolobxMixin = function(stores) {
  let appState = {};

  Object.keys(stores).forEach( key => {
    const store = mobx.observable(stores[key].store);
    const actions = stores[key].actions;

    appState[key] = {
      store,
      actions
    };
  });

  function dispatch({store, action, payload}) {
    if (appState[store] && appState[store].actions && appState[store].actions[action]) {
      const storeAction = appState[store].actions[action];

      mobx.action(storeAction.bind(appState[store], [payload]))();

      return appState[store];
    }

    console.warn(`No action "${action}" for "${store}" store`);
  };

  mobx.useStrict(true);

  return subclass => class extends subclass {

    constructor() {
      super();

      this._appState = appState;
      this.dispatch = dispatch;
    }

    connectedCallback() {
      super.connectedCallback();

      const properties = this.constructor.config.properties;

      if (properties) {
        for (let property in properties) {
          const statePath = properties[property].statePath;

          if (statePath && this._appState[statePath.store]) {
            mobx.autorun(() => {
              const store = this._appState[statePath.store].store;
              this[property] = store[statePath.path];
            });
          }
        }
      }

    }
  };
};<commit_msg>Use behavior instead mixin to Polymer 1.x compatibility<commit_after>const createPolobxBehavior = function(stores) {
  let appState = {};

  Object.keys(stores).forEach( key => {
    const store = mobx.observable(stores[key].store);
    const actions = stores[key].actions;

    appState[key] = {
      store,
      actions
    };
  });

  function dispatch({store, action, payload}) {
    if (appState[store] && appState[store].actions && appState[store].actions[action]) {
      const storeAction = appState[store].actions[action];

      mobx.action(storeAction.bind(appState[store], [payload]))();

      return appState[store];
    }

    console.warn(`No action "${action}" for "${store}" store`);
  };

  mobx.useStrict(true);

  return {

    created() {
      this._appState = appState;
      this.dispatch = dispatch;
    }

    attached() {
      const properties = this.constructor.config.properties;

      if (properties) {
        for (let property in properties) {
          const statePath = properties[property].statePath;

          if (statePath && this._appState[statePath.store]) {
            mobx.autorun(() => {
              const store = this._appState[statePath.store].store;
              this[property] = store[statePath.path];
            });
          }
        }
      }

    }
  };
};
{'fraction_non_alphanumeric': 0.14057270360728896, 'fraction_numerical': 0.0003718854592785422, 'mean_word_length': 2.544137022397892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '6751542', 'n_tokens_mistral': 795, 'n_tokens_neox': 767, 'n_words': 147}