src/handlers.js
function set (target, key, value, receiver) {
  // make sure to do not pollute the raw object with observables
  if (typeof value === 'object' && value !== null) {
    value = proxyToRaw.get(value) || value
  }
  // save if the object had a descriptor for this key
  const hadKey = hasOwnProperty.call(target, key)
  // save if the value changed because of this set operation
  const oldValue = target[key]
  // execute the set operation before running any reaction
  const result = Reflect.set(target, key, value, receiver)
  // do not queue reactions if the target of the operation is not the raw receiver
  // (possible because of prototypal inheritance)
  if (target !== proxyToRaw.get(receiver)) {
    return result
  }
  // queue a reaction if it's a new property or its value changed
  if (!hadKey) {
    queueReactionsForOperation({ target, key, value, receiver, type: 'add' })
  } else if (value !== oldValue) {
    queueReactionsForOperation({
      target,
      key,
      value,
      oldValue,
      receiver,
      type: 'set'
    })
  }
  return result
}
function set (target, key, value, receiver) {
  // make sure to do not pollute the raw object with observables
  if (typeof value === 'object' && value !== null) {
    value = proxyToRaw.get(value) || value
  }
  // save if the object had a descriptor for this key
  const hadKey = hasOwnProperty.call(target, key)
  // save if the value changed because of this set operation
  const oldValue = target[key]
  // execute the set operation before running any reaction
  const result = Reflect.set(target, key, value, receiver)
  // do not queue reactions if the target of the operation is not the raw receiver
  // (possible because of prototypal inheritance)
  if (target !== proxyToRaw.get(receiver)) {
    return result
  }
  // queue a reaction if it's a new property or its value changed
  if (!hadKey) {
    queueReactionsForOperation({ target, key, value, receiver, type: 'add' })
  } else if (value !== oldValue) {
    queueReactionsForOperation({
      target,
      key,
      value,
      oldValue,
      receiver,
      type: 'set'
    })
  }
  return result
}
function set ( target , key , value , receiver ) { // make sure to do not pollute the raw object with observables if ( typeof value === 'object' && value !== null ) { value = proxyToRaw . get ( value ) || value } // save if the object had a descriptor for this key const hadKey = hasOwnProperty . call ( target , key ) // save if the value changed because of this set operation const oldValue = target [ key ] // execute the set operation before running any reaction const result = Reflect . set ( target , key , value , receiver ) // do not queue reactions if the target of the operation is not the raw receiver // (possible because of prototypal inheritance) if ( target !== proxyToRaw . get ( receiver ) ) { return result } // queue a reaction if it's a new property or its value changed if ( ! hadKey ) { queueReactionsForOperation ( { target , key , value , receiver , type : 'add' } ) } else if ( value !== oldValue ) { queueReactionsForOperation ( { target , key , value , oldValue , receiver , type : 'set' } ) } return result }
intercept set operations on observables to know when to trigger reactions
intercept set operations on observables to know when to trigger reactions