batchedEffect Helper¶
Basic Overload¶
-
template<typename ...Sources>
BatchedEffect<Sources...> RxESP32::Helpers::Utility::batchedEffect(typename Effect<1>::EffectFunction action_fn, uint32_t batch_window_ms, Sources&... sources)¶ Create a BatchedEffect that groups rapid source updates into single action execution.
Factory function to create a BatchedEffect with default options.
- Since
v0.1.0
Signal<int> sensor1(0); Signal<int> sensor2(0); int times_effect_run = 0; // Effect that is batched with 100ms delay auto effect = batchedEffect([]() { times_effect_run++; Serial.println("Batched effect executed"); return nullptr; }, 100, sensor1, sensor2); // Rapid updates to sensors sensor1.set(10); sensor2.set(20); sensor1.set(30); sensor2.set(40); // Effect runs only once after 100msNote
Internally uses debounce helper.
With Options¶
-
template<typename ...Sources>
BatchedEffect<Sources...> RxESP32::Helpers::Utility::batchedEffect(typename Effect<1>::EffectFunction action_fn, uint32_t batch_window_ms, const typename Effect<1>::Options &options, Sources&... sources)¶ Create a BatchedEffect that groups rapid source updates into single action execution.
Factory function to create a BatchedEffect with custom options.
- Since
v0.1.0
Signal<int> sensor1(0); Signal<int> sensor2(0); int times_effect_run = 0; // Effect that is batched with 100ms delay and custom options auto effect = batchedEffect([]() { times_effect_run++; Serial.println("Batched effect executed"); return nullptr; }, 100, {.name = "BatchedEffect"}, sensor1, sensor2); // Rapid updates to sensors sensor1.set(10); sensor2.set(20); sensor1.set(30); sensor2.set(40); // Effect runs only once after 100msNote
Internally uses debounce helper.
See Also¶
Utility Helpers - Overview