<commit_before>import {object, isFunction} from './utils.js';
import {stateTriggers, componentRef} from './constants'


let setStateFunc = (componentInstance, newState) => {
  //let newState = noKey ? state : object([key], [state]);
  if (typeof componentInstance.isMounted === "undefined" || componentInstance.isMounted() === true) {
    componentInstance.setState(newState);
  }
};

let getInitialStateFunc = (noKey, store, key, componentName)=> {
  if (!isFunction(store.getInitialState)) {
    console.warn('component ' + componentName + ' is trying to connect to a store that lacks "getInitialState()" method');
    return {};
  } else {
    let storeState = store.state;
    //return noKey ? storeState : storeState[key];

    return noKey ? storeState : object([key], [storeState[key]]);
  }
};

let subscribe = (noKey, store, key, componentInstance)=> {
  let listener = noKey ? store : store[stateTriggers][key];

  this.unsubscribe = listener.listen((dataObj)=> {
    //store triggers storeState or storeState.key
    let newState = noKey ? dataObj : object([key], [dataObj]);
    setStateFunc(componentInstance, newState)
  });
};
<commit_msg>pass 'isMounted' test<commit_after>import {object, isFunction} from './utils.js';
import {stateTriggers, componentRef} from './constants'


let setStateFunc = (componentInstance, newState) => {
  //let newState = noKey ? state : object([key], [state]);
  //if (typeof componentInstance.isMounted === "undefined" || componentInstance.isMounted() === true) {
    componentInstance.setState(newState);
  //}
};

let getInitialStateFunc = (noKey, store, key, componentName)=> {
  if (!isFunction(store.getInitialState)) {
    console.warn('component ' + componentName + ' is trying to connect to a store that lacks "getInitialState()" method');
    return {};
  } else {
    let storeState = store.state;
    //return noKey ? storeState : storeState[key];

    return noKey ? storeState : object([key], [storeState[key]]);
  }
};

let subscribe = (noKey, store, key, componentInstance)=> {
  let listener = noKey ? store : store[stateTriggers][key];

  this.unsubscribe = listener.listen((dataObj)=> {
    //store triggers storeState or storeState.key
    let newState = noKey ? dataObj : object([key], [dataObj]);
    setStateFunc(componentInstance, newState)
  });
};

{'fraction_non_alphanumeric': 0.15, 'fraction_numerical': 0.0, 'mean_word_length': 4.461176470588235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6407792', 'n_tokens_mistral': 697, 'n_tokens_neox': 690, 'n_words': 178}