untracked

template<typename Func>
auto RxESP32::untracked(Func &&func) -> decltype(func())

Execute a function without tracking dependencies.

Runs the provided function in an “untracked” context where any Signal or Computed reads will not be registered as dependencies. This is useful when you need to read reactive values for conditional logic or debugging without creating unwanted dependency relationships.

Since

v0.1.0

Signal<int> counter(0);
Signal<bool> debug_mode(false);

// This computed only depends on counter, not debug_mode
Computed<int> doubled([]() {
  int value = counter.get();  // Creates dependency on counter

  // Read debug_mode without creating dependency
  bool debug = untracked([]() { return debug_mode.get(); });

  if (debug) {
    Serial.printf("Computing: %d * 2\n", value);
  }

  return value * 2;  // Only recomputes when counter changes
});

Note

You can accomplish the same effect using Signal::peek() or Computed::peek() for individual reads, but untracked() is more convenient for multiple reads or complex logic.

Template Parameters:
typename Func

The function type to execute (auto-deduced).

Parameters:
Func &&func

The function to execute without dependency tracking.

Returns:

The result of the function.

See Also