pub fn when<T, F>(
condition: &Behavior<bool>,
then_value: F,
) -> Behavior<Option<T>>Expand description
Conditional combinator - select between values based on a condition
Creates a behavior that follows the value of then_value when condition
is true, otherwise it holds None.
ยงExample
use cliffy_core::{behavior, when};
let show_message = behavior(true);
let message = when(&show_message, || "Hello!".to_string());
assert_eq!(message.sample(), Some("Hello!".to_string()));
show_message.set(false);
assert_eq!(message.sample(), None);