macro_rules! update {
    (|$ident:ident $(,)?| $body:expr) => { ... };
    (move |$ident:ident $(,)?| $body:expr) => { ... };
    (|$first:ident, $($rest:ident),+ $(,)? | $body:expr) => { ... };
    (move |$first:ident, $($rest:ident),+ $(,)? | $body:expr) => { ... };
}
Expand description

Provides a simpler way to use SignalUpdate::update.

This macro also supports stored values. If you would like to distinguish between the two, you can also use update_value for stored values only.

The general syntax looks like:

update!(|capture1, capture2, ...| body);

The variables within the ‘closure’ arguments are captured from the environment, and can be used within the body with the same name.

move can also be added before the closure arguments to add move to all expanded closures.

§Examples

let a = create_rw_signal(1);
let b = create_rw_signal(2);
update!(|a, b| *a = *a + *b);
assert_eq!(a.get(), 3);

The update! macro in the above example expands to:

a.update(|a| {
    b.update(|b| *a = *a + *b)
})

If move is added:

update!(move |a, b| *a = *a + *b + something_else)

Then all closures are also move.

first.update(move |a| {
    last.update(move |b| *a = *a + *b + something_else)
})