timeTravel method

void timeTravel(
  1. String id,
  2. int historyIndex
)

Time travel - restore signal to a previous value.

Implementation

void timeTravel(String id, int historyIndex) {
  if (!_enabled) return;

  final signal = signals[id];
  final history = getHistory(id);
  if (history == null || signal == null) return;
  if (historyIndex < 0 || historyIndex >= history.length) return;
  final value = history[historyIndex];
  if (signal is Signal) {
    signal.emit(value);
  } else {
    // ignore: invalid_use_of_protected_member
    signal.value = value;
  }
}