<commit_before>
import getPath from './getPath'
import createDataListener from './createDataListener'

function updateInstanceData(db, schema, props, data, self, prop, val) {

  // Unsubscribe all listeners for this prop
  props.schema.subscribes[prop].forEach(y => y())
  props.schema.subscribes[prop] = []

  // For all the paths that are impacted by this prop
  props.schema.tokens[prop].props.forEach(x => {
    let path = getPath(schema, props, self, x)

    let listener = createDataListener(db, path, data, x)

    props.schema.subscribes[prop].push(listener)
  })

}

export default updateInstanceData<commit_msg>Fix error on view when token or subscribes props are undefined<commit_after>
import getPath from './getPath'
import createDataListener from './createDataListener'

function updateInstanceData(db, schema, props, data, self, prop, val) {

  // Unsubscribe all listeners for this prop
  if (props.schema.subscribes[prop]) {
    props.schema.subscribes[prop].forEach(y => y())
  }

  props.schema.subscribes[prop] = []

  // For all the paths that are impacted by this prop
  if (props.schema.tokens[prop] && props.schema.tokens[prop].props) {
    props.schema.tokens[prop].props.forEach(x => {
      let path = getPath(schema, props, self, x)

      let listener = createDataListener(db, path, data, x)

      props.schema.subscribes[prop].push(listener)
    })
  }
}

export default updateInstanceData
{'fraction_non_alphanumeric': 0.12042253521126761, 'fraction_numerical': 0.0, 'mean_word_length': 4.111510791366906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2964701', 'n_tokens_mistral': 436, 'n_tokens_neox': 423, 'n_words': 120}