Lift

Derive Macro Lift 

Source
#[derive(Lift)]
Expand description

Derive macro to lift a struct into a reactive Signal.

Applying #[derive(Lift)] to a struct generates an inner unwrapped struct and a lift(self) method that produces a crate::signal::Signal<'a, _Inner> where any fields of type Signal<'a, T> are replaced by their inner T in the generated inner struct. The generated lift method wires up reactions so that changes to any signal fields propagate into the resulting lifted Signal.

Example:

use crate::signal::Signal;

#[derive(Lift)]
struct Example<'a> {
    a: Signal<'a, i32>,
    b: String,
}

let example = Example { a: Signal::new(1), b: "hi".to_string() };
let lifted = example.lift(); // Signal<'a, _Example>
lifted.with(|inner| println!("a = {}", inner.a));