whenAny Helper¶
Basic Overload¶
-
template<typename Condition, typename Callback, typename Source1, typename ...Sources>
auto RxESP32::Helpers::Combinatorial::whenAny(Condition &&condition, Callback &&callback, Source1 &source1, Sources&... sources)¶ Execute callback when any source satisfies a condition.
Creates an Effect that monitors multiple sources and executes a callback when ANY source satisfies the given condition.
- Since
v0.1.0
Signal<bool> sensor1(false), sensor2(false), sensor3(false); auto alert = whenAny( [](bool v) { return v; }, // Any sensor true [](bool a, bool b, bool c) { // Callback Serial.println("Alert triggered!"); }, 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::whenAny(Condition &&condition, Callback &&callback, const typename Effect<1 + sizeof...(Sources)>::Options &options, Source1 &source1, Sources&... sources)¶ Execute callback when any source satisfies a condition with options.
Creates an Effect that monitors multiple sources and executes a callback when ANY source satisfies the given condition, with custom options.
- Since
v0.1.0
Signal<bool> sensor1(false), sensor2(false), sensor3(false); auto alert = whenAny( [](bool v) { return v; }, // Any sensor true [](bool a, bool b, bool c) { // Callback Serial.println("Alert triggered!"); }, {.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 any satisfies 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 whenAny behavior.
See Also¶
Combinatorial Helpers - Overview