Internal method called every time a entity in the set fires an event. Sets need to update their indexes when entities change ids. All other events simply proxy through. "add" and "remove" events that originate in other collections are ignored.
194114
function(event, entity, collection, options) {
      if (entity) {
        if ((event === 'add' || event === 'remove') && collection !== this) return;
        if (event === 'destroy') this.remove(entity, options);
        if (event === 'change') {
          var prevId = this.entityId(entity.previousAttributes());
          var id = this.entityId(entity.attributes);
          if (prevId !== id) {
            if (prevId != null) delete this._byId[prevId];
            if (id != null) this._byId[id] = entity;
          }
        }
      }
      this.trigger.apply(this, arguments);
    }
290295
void setChanged() {

        enableSave();
        m_changedEntityIds.add(m_entityId);
        m_deletedEntities.remove(m_entityId);
        updateOverlayPosition();
        setEditorState(true);
    }
1298234
function(entities, options) {
      var removed = [];
      for (var i = 0; i < entities.length; i++) {
        var entity = this.get(entities[i]);
        if (!entity) continue;

        var index = this.indexOf(entity);
        this.entities.splice(index, 1);
        this.length--;

        // Remove references before triggering 'remove' event to prevent an
        // infinite loop. #3693
        delete this._byId[entity.cid];
        var id = this.entityId(entity.attributes);
        if (id != null) delete this._byId[id];

        if (!options.silent) {
          options.index = index;
          entity.trigger('remove', entity, this, options);
        }

        removed.push(entity);
        this._removeReference(entity, options);
      }
      return removed;
    }
1246523
public void updateIndex(Set<String> addedNodes, Set<String> removedNodes, Set<String> parentAddedNodes,
      Set<String> parentRemovedNodes)
   {
      // pass lists to search manager 
      if (searchManager != null && (addedNodes.size() > 0 || removedNodes.size() > 0))
      {
         try
         {
            searchManager.updateIndex(removedNodes, addedNodes);
         }
         catch (RepositoryException e)
         {
            log.error("Error indexing changes " + e, e);
         }
         catch (IOException e)
         {
            log.error("Error indexing changes " + e, e);
            try
            {
               handler.logErrorChanges(removedNodes, addedNodes);
            }
            catch (IOException ioe)
            {
               log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
            }
         }
      }
      // pass lists to parent search manager 
      if (parentSearchManager != null && (parentAddedNodes.size() > 0 || parentRemovedNodes.size() > 0))
      {
         try
         {
            parentSearchManager.updateIndex(parentRemovedNodes, parentAddedNodes);
         }
         catch (RepositoryException e)
         {
            log.error("Error indexing changes " + e, e);
         }
         catch (IOException e)
         {
            log.error("Error indexing changes " + e, e);
            try
            {
               parentHandler.logErrorChanges(parentRemovedNodes, parentAddedNodes);
            }
            catch (IOException ioe)
            {
               log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
            }
         }
      }
   }
846799
function onChangeDetected ({ entity, properties }) {

  // Fetch extensions implementing .onChangeDetected(...) method
  let extensions = _.filter(this.extensions, (extension) => {
    return extension.implemented.onChangeDetected;
  });

  // Create a proxy .onChangeDetected(...) method
  this.onChangeDetected =  (event) => {
    // Execute all extensions' .onChangeDetected(...) method
    _.forEach(extensions, (extension) => {
      extension.onChangeDetected(entity, properties, event);
    });
  };

}
1326317
protected void refreshIndexes(Set<String> set)
   {
      // do nothing if null is passed
      if (set == null)
      {
         return;
      }
      setNames(set);
      // callback multiIndex to refresh lists
      try
      {
         MultiIndex multiIndex = getMultiIndex();
         if (multiIndex != null)
         {
            multiIndex.refreshIndexList();
         }
      }
      catch (IOException e)
      {
         LOG.error("Failed to update indexes! " + e.getMessage(), e);
      }
   }
115174
public void addListeners(PropertyChangeListener listener, Object newObject, Set updateSet) {
        removeListeners();
        if (newObject != null) {
            // check for local synthetics
            TriggerBinding syntheticTrigger = getSyntheticTriggerBinding(newObject);
            MetaClass mc = InvokerHelper.getMetaClass(newObject);
            if (syntheticTrigger != null) {
                PropertyBinding psb = new PropertyBinding(newObject, propertyName);
                PropertyChangeProxyTargetBinding proxytb = new PropertyChangeProxyTargetBinding(newObject, propertyName, listener);

                syntheticFullBinding = syntheticTrigger.createBinding(psb, proxytb);
                syntheticFullBinding.bind();
                updateSet.add(newObject);
            } else if (!mc.respondsTo(newObject, "addPropertyChangeListener", NAME_PARAMS).isEmpty()) {
                InvokerHelper.invokeMethod(newObject, "addPropertyChangeListener", new Object[] {propertyName, listener});
                localListener = listener;
                updateSet.add(newObject);
            } else if (!mc.respondsTo(newObject, "addPropertyChangeListener", GLOBAL_PARAMS).isEmpty()) {
                InvokerHelper.invokeMethod(newObject, "addPropertyChangeListener", listener);
                globalListener = listener;
                updateSet.add(newObject);
            }
        }
        currentObject = newObject;
    }
878267
function interceptPropertySet ({ entity, properties }) {
  // Create a proxy .interceptPropertySet(...) methods, per property
  this.interceptPropertySet = _.reduce(properties, (interceptPropertySet, propertyConfiguration, propertyName) => {

    // Fetch extensions implementing .interceptPropertySet(...) method for this property's interceptor functions
    let setterInterceptors = _.compact(
      _.map(this.extensions, (extension) => {
        // Check if implementing .interceptPropertySet(...) method
        if (extension.implemented.interceptPropertySet) {
          // Return the setter interceptor function (if returned for this property)
          return extension.interceptPropertySet(propertyName, propertyConfiguration);
        }
      })
    );

    // Initialize a per-property setter intercepting function and returns the updated value
    interceptPropertySet[propertyName] = (currentValue, newValue) => {

      // Initialize the EnTTExtValueEvent event
      let changes = [ currentValue, newValue ],
          event = new EnTTExtValueEvent({
        changes,
        currentValue,
        value: newValue,
      });

      // Cycle through all the setter interceptors
      _.forEach(setterInterceptors, (setterInterceptor) => {
        // Execute the extensino intercaptor
        setterInterceptor(entity, properties, event);
        // Update the changes array for the next interceptor
        changes.push(event.value);
      });

      // Return the updated value
      return event.value;

    };

    // Return composed interceptors
    return interceptPropertySet;

  }, {});
}
202922
protected void fireLayerAddedEvent(MapLayer layer, int index) {
		fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer, Type.ADD_CHILD, index, layer.isTemporaryLayer()));
	}
208296
def orify(e, changed_callback):
    
    if not hasattr(e, "callbacks"):  # Event has not been orified yet
        e._set = e.set
        e._clear = e.clear
        e.set = lambda: or_set(e)
        e.clear = lambda: or_clear(e)
        e.callbacks = list()
    # Keep track of one callback per multi event
    e.callbacks.append(changed_callback)
150608
@Override
    public void changed(Database.ChangeEvent event) {
        synchronized (changesLock) {
            if (isTimeout)
                return;

            lastChangesTimestamp = System.currentTimeMillis();

            // Stop timeout timer:
            stopTimeout();

            // In race condition, new doc or update doc is fired before starting to observe the
            // DatabaseChangeEvent, it allows to skip few document changes with /_changes REST API.
            // Make sure all document changes are tread by /_changes REST API.
            if (!filled) {
                filled = true;
                RevisionList changes = db.changesSince(changesSince, changesOptions,
                        changesFilter, changesFilterParams);
                if (changes.size() > 0) {
                    sendLongpollChanges(changes, changesSince);
                    return;
                }
            }

            List<RevisionInternal> revs = new ArrayList<RevisionInternal>();
            List<DocumentChange> changes = event.getChanges();
            for (DocumentChange change : changes) {
                RevisionInternal rev = change.getAddedRevision();
                if (rev == null)
                    continue;
                String winningRevID = change.getWinningRevisionID();
                if (!this.changesIncludesConflicts) {
                    if (winningRevID == null)
                        continue; // // this change doesn't affect the winning rev ID, no need to send it
                    else if (!winningRevID.equals(rev.getRevID())) {
                        // This rev made a _different_ rev current, so substitute that one.
                        // We need to emit the current sequence # in the feed, so put it in the rev.
                        // This isn't correct internally (this is an old rev so it has an older sequence)
                        // but consumers of the _changes feed don't care about the internal state.
                        RevisionInternal mRev = db.getDocument(rev.getDocID(), winningRevID, changesIncludesDocs);
                        mRev.setSequence(rev.getSequence());
                        rev = mRev;
                    }
                }

                if (!event.getSource().runFilter(changesFilter, changesFilterParams, rev))
                    continue;

                if (longpoll) {
                    revs.add(rev);
                } else {
                    Log.d(TAG, "Router: Sending continuous change chunk");
                    sendContinuousChange(rev);
                }

                timeoutLastSeqence = rev.getSequence();
            }

            if (longpoll && revs.size() > 0)
                sendLongpollChanges(revs, changesSince);
            else
                // Restart timeout timer for continuous feed request:
                startTimeout();
        }
    }
1297549
function setEventData(events) { // events are already normalized at this point
		eventsByID = {};
		var i, len=events.length, event;
		for (i=0; i<len; i++) {
			event = events[i];
			if (eventsByID[event._id]) {
				eventsByID[event._id].push(event);
			}else{
				eventsByID[event._id] = [event];
			}
		}
	}
1284785
def _set_id(self, Id, is_added, index):
        """"""
        if is_added:
            self.selected_ids.add(Id)
        else:
            self.selected_ids.remove(Id)
        self.dataChanged.emit(index, index)
929516
function(event, model, collection, options) {
      if ((event === 'add' || event === 'remove') && collection !== this) return;
      if (event === 'destroy') this.remove(model, options);
      if (event === 'change') {
        var prevId = this.modelId(model.previousAttributes());
        var id = this.modelId(model.attributes);
        if (prevId !== id) {
          if (prevId != null) delete this._byId[prevId];
          if (id != null) this._byId[id] = model;
        }
      }
      this.trigger.apply(this, arguments);
    }
199892
@Override
    protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders)
    {
        JsonDocument doc = handler.getDocumentFromEntity(entityMetadata, entity, kunderaMetadata);

        if (!isUpdate)
        {
            bucket.insert(doc);
            LOGGER.debug("Inserted document with ID : " + doc.id() + " in the " + bucket.name() + " Bucket");
        }
        else
        {
            bucket.upsert(doc);
            LOGGER.debug("Updated document with ID : " + doc.id() + " in the " + bucket.name() + " Bucket");
        }
    }
978206
def apply_events(events)
      events.each do |event|
        method_name = event_handler(event)
        public_send(method_name, event.data) if respond_to?(method_name)
      end
      @revision = events.last&.revision.to_i if events.last.respond_to?(:revision)
    end
1177763
function(ev, model, collection, options) {
      if ((ev === 'add' || ev === 'remove') && collection !== this) {
        return;
      }
      if (ev === 'destroy') {
        this.remove(model, options);
      }
      if (model && ev === 'change:objectId') {
        delete this._byId[model.previous("objectId")];
        this._byId[model.id] = model;
      }
      this.trigger.apply(this, arguments);
    }