whenAll Helper¶
Basic Overload¶
-
template<typename Condition, typename Callback, typename Source1, typename ...Sources>
auto RxESP32::Helpers::Combinatorial::whenAll(Condition &&condition, Callback &&callback, Source1 &source1, Sources&... sources)¶ Execute callback when all sources satisfy a condition.
Creates an Effect that monitors multiple sources and executes a callback only when ALL sources satisfy the given condition.
- Since
v0.1.0
Signal<int> sensor1(0), sensor2(0), sensor3(0); auto ready = whenAll( [](int v) { return v > 10; }, // Condition [](int a, int b, int c) { // Callback Serial.printf("All ready: %d, %d, %d\n", a, b, c); }, sensor1, sensor2, sensor3 );Note
Callback receives all source values.
Warning
Requires at least 2 sources.
All sources must have the same type.
Condition must accept source type and return
bool.
With Options¶
-
template<typename Condition, typename Callback, typename Source1, typename ...Sources>
auto RxESP32::Helpers::Combinatorial::whenAll(Condition &&condition, Callback &&callback, const typename Effect<1 + sizeof...(Sources)>::Options &options, Source1 &source1, Sources&... sources)¶ Execute callback when all sources satisfy a condition with options.
Creates an Effect that monitors multiple sources and executes a callback only when ALL sources satisfy the given condition, with custom options.
- Since
v0.1.0
Signal<int> sensor1(0), sensor2(0), sensor3(0); auto ready = whenAll( [](int v) { return v > 10; }, // Condition [](int a, int b, int c) { // Callback Serial.printf("All ready: %d, %d, %d\n", a, b, c); }, {.lazy = true}, // Options sensor1, sensor2, sensor3 );Note
Callback receives all source values.
Warning
Requires at least 2 sources.
All sources must have the same type.
Condition must accept source type and return
bool.
- Parameters:¶
- Condition &&condition¶
Predicate to test each source value.
- Callback &&callback¶
Function to execute when all satisfy condition.
- const typename Effect<1 + sizeof...(Sources)>::Options &options¶
Effect configuration options.
- Source1 &source1¶
First source (determines result type).
- Sources&... sources¶
Additional sources (must match
source1type).
- Returns:¶
Effect managing the whenAll behavior.
See Also¶
Combinatorial Helpers - Overview