batch Helper

template<typename Func, typename ...Signals>
void RxESP32::Helpers::Utility::batch(Func &&func, Signals&... signals)

Execute multiple signal changes as a single batch.

Freezes all provided signals, executes the function, then unfreezes them. Only the last Signal’s unfreeze triggers notifications, ensuring dependents only recompute once instead of after each individual change.

Since

v0.1.0

Signal<int> x(0), y(0), z(0);
Computed<int> sum([&]() { return x.get() + y.get() + z.get(); });

// Without batch: sum recomputes 3 times
x.set(10);
y.set(20);
z.set(30);

// With batch: sum recomputes only once
batch([]() {
  x.set(10);
  y.set(20);
  z.set(30);
}, x, y, z);

Note

  • All signals are frozen/unfrozen atomically.

  • Only one notification occurs after unfreezing (the last Signal).

  • Function is executed immediately (blocking).

Parameters:
Func &&func

Function to execute while signals are frozen (auto-deduced).

Signals&... signals

Signal’s to freeze during batch operation (auto-deduced).

See Also