Module silkenweb::accumulators[][src]

Accumulate reactive variables into a reactive total.

The example below shows how to sum up first_digit and second_digit into total. When we drop first_digit, it is removed from the total.

 let total = SumTotal::<usize>::default();
 let first_digit = SumElement::new(&total);
 let second_digit = SumElement::new(&total);
 let total = total.read();

 first_digit.receive(&1);
 assert_eq!(1, *total.current());
 second_digit.receive(&10);
 assert_eq!(11, *total.current());

 mem::drop(first_digit);
 assert_eq!(10, *total.current());

Structs

SumElement

A single element of the sum.

SumHandle

A handle to keep a value in the sum.

SumTotal

This holds the current total of a sum.