check change between two states and triggers
174746
function Edge(a, b) {
  var s = 0;
  function t() {}
  a._story(null, function() {
    if(s !== 0) {
      t.trigger();
    }
    s = 0;
  });
  b._story(null, function() {
    if(s !== 1) {
      t.trigger();
    }
    s = 1;
  });
  return Trigger(t);
}
797190
function(attr, how, newVal, oldVal) {
                    can.batch.trigger(this, "change", can.makeArray(arguments));
                }
802462
function applyStateChanges(state, changes) {
  let result = false;

  // Applying the changes may produce a new round of changes, and that round
  // might produce new changes, and so on. Loop until we complete a pass that
  // produces no changes.
  for (
    let changed;
    changed = fieldsChanged(state, changes), !isEmpty(changed);
  ) {
    // We do have some real changes to report.
    result = true;

    // Apply the changes to the state.
    Object.assign(state, changes);

    // Run the change handlers, gathering up the changes those produce.
    const nextChanges = {};
    if (state[changeHandlersKey]) {
      state[changeHandlersKey].forEach(handler => {
        const { dependencies, callback } = handler;
        // Does this handler trigger on any of the changes we have?
        const run = dependencies.some(dependency => changed[dependency]);
        if (run) {
          // Yes, run the change handler and collect its changes.
          const handlerChanges = callback(state, changed);
          Object.assign(nextChanges, handlerChanges);
        }
      });
    }

    // If the change handlers produced changes, we'll run the loop again.
    changes = nextChanges;
  }

  return result;
}
105222
private void processStateChanges(final Map<String, String> changes) {
        workflowEngine.event(WorkflowSystemEventType.WillProcessStateChange,
                             String.format("saw state changes: %s", changes), changes
        );

        workflowEngine.getState().updateState(changes);

        boolean update = Rules.update(workflowEngine.getRuleEngine(), workflowEngine.getState());
        workflowEngine.event(
                WorkflowSystemEventType.DidProcessStateChange,
                String.format(
                        "applied state changes and rules (changed? %s): %s",
                        update,
                        workflowEngine.getState()
                ),
                workflowEngine.getState()
        );
    }
883721
def async_state_change_callback(self, addr, state, value):
        """"""
        _LOGGING.info('Device %s state %s value is changed to %s',
                      addr, state, value)
1092321
def check(self):
        """"""
        has_term = False

        if self.START_STATE not in self.states:
            raise SyntaxError('Undefined start rule')

        for state in self.states:
            for rule in self.states[state]:
                if rule is not None:
                    if rule[2] == self.TERM_STATE:
                        has_term = True
                    elif rule[2] not in self.states:
                        raise SyntaxError('Unexpected state: ' + rule[2])

        if not has_term:
            raise SyntaxError('Missed terminate state')
915347
@Override
    public Trigger.TriggerState getTriggerState(TriggerKey triggerKey, JedisCluster jedis) {
        final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
        Map<RedisTriggerState, Double> scores = new HashMap<>(RedisTriggerState.values().length);
        for (RedisTriggerState redisTriggerState : RedisTriggerState.values()) {
            scores.put(redisTriggerState, jedis.zscore(redisSchema.triggerStateKey(redisTriggerState), triggerHashKey));
        }
        for (Map.Entry<RedisTriggerState, Double> entry : scores.entrySet()) {
            if (entry.getValue() != null) {
                return entry.getKey().getTriggerState();
            }
        }
        return Trigger.TriggerState.NONE;
    }
904053
function getChangedBits({ state: prevState }, { state: nextState }) {
    let mask = 0
    for (let id in nextState) {
      if (prevState[id] !== nextState[id]) {
        mask |= NAME_BITS[id]
      }
    }
    return mask
  }
656032
private boolean performStateCheck(final int increment) {
        CheckIntervalData currentData;
        CheckIntervalData nextData;
        State currentState;

        do {
            final long time = now();
            currentState = state.get();
            currentData = checkIntervalData.get();
            nextData = nextCheckIntervalData(increment, currentData, currentState, time);
        } while (!updateCheckIntervalData(currentData, nextData));

        // This might cause a race condition if other changes happen in between!
        // Refer to the header comment!
        if (stateStrategy(currentState).isStateTransition(this, currentData, nextData)) {
            currentState = currentState.oppositeState();
            changeStateAndStartNewCheckInterval(currentState);
        }
        return !isOpen(currentState);
    }
49161
def __check_state(self):
        """"""
        state = self.__read_device()
        if not state:
            raise UnpluggedError(
                "Gamepad %d is not connected" % self.__device_number)
        if state.packet_number != self.__last_state.packet_number:
            # state has changed, handle the change
            self.__handle_changed_state(state)
            self.__last_state = state
173171
function(compute, newValue, oldValue, batchNum){

	var valueChanged = newValue !== oldValue && !(newValue !== newValue && oldValue !== oldValue);
	// Only trigger event when value has changed
	if (valueChanged) {
		compute.dispatch({type: "change", batchNum: batchNum}, [
			newValue,
			oldValue
		]);
	}
}
251782
@SuppressWarnings("squid:S1698")
    public boolean wasTriggeredBy(String... triggers) {
        if (triggers.length == 0) {
            return false;
        }
        for (String aTrigger : triggers) {
            if (aTrigger != null && aTrigger.intern() == getTrigger()) {
                return true;
            }
        }

        return false;
    }
1212734
def trigger_all_change_callbacks(self):
        """"""
        return [
            ret
            for key in DatastoreLegacy.store[self.domain].keys()
            for ret in self.trigger_change_callbacks(key)
        ]
181313
@Override
	public boolean changeTrigger(JobTriggerTO triggerTO, boolean add) throws SchedulerException {
		if (!config.isChangeTriggerAllowed()) {
			LOGGER.warn("not allowed to change any trigger");
			return false;
		}
		JobDetail detail = findJob(triggerTO.getOriginalJobGroup(), triggerTO.getOriginalJobName());
		if (null == detail) {
			return false;
		}
		Trigger trigger = findTrigger(triggerTO.getOriginalJobGroup(), triggerTO.getOriginalJobName(), 
				triggerTO.getOriginalTriggerGroup(), triggerTO.getOriginalTriggerName());
		if(null == trigger) {
			if (add) {
				this.scheduler.scheduleJob(buildTrigger(detail, null, triggerTO));
				return true;
			}
			return false;
		}
		this.scheduler.rescheduleJob(trigger.getKey(), buildTrigger(detail, trigger, triggerTO));
		return true;
	}
738071
public static void checkState(boolean b, String msg, long arg1, long arg2, long arg3, long arg4) {
        if (!b) {
            throwStateEx(msg, arg1, arg2, arg3, arg4);
        }
    }
929562
private boolean hasChanges(final Map<URI, URI> changeTable) {
        if (changeTable.isEmpty()) {
            return false;
        }
        for (Map.Entry<URI, URI> e : changeTable.entrySet()) {
            if (!e.getKey().equals(e.getValue())) {
                return true;
            }
        }
        return false;
    }
810887
def process(self, new_state=None):
        
        if new_state is None:
            new_state = set(self.buttons_pressed)
        old_state = self._state
        self._state = new_state

        state_diff = new_state.symmetric_difference(old_state)
        for button in state_diff:
            handler = getattr(self, 'on_' + button)

            if handler is not None:
                handler(button in new_state)

        if self.on_change is not None and state_diff:
            self.on_change([(button, button in new_state) for button in state_diff])