pub fn bind<S, T>(
binding: impl Binding<S>,
lens: impl Lens<S, T>,
) -> impl Binding<T>where
S: 'static,
T: 'static,Examples found in repository?
More examples
examples/counter_list.rs (line 8)
3fn main() {
4 rui(state(Counters::default, |counters, cx| {
5 vstack((
6 list(cx[counters].ids(), move |&i| {
7 with_cx(move |cx| {
8 let count = bind(counters, CounterLens(i));
9 hstack((
10 format!("{}", count.get(cx)).padding(Auto),
11 button("increment", move |cx| {
12 *count.get_mut(cx) += 1;
13 })
14 .padding(Auto),
15 button("decrement", move |cx| {
16 *count.get_mut(cx) -= 1;
17 })
18 .padding(Auto),
19 button("remove", move |cx| cx[counters].remove_counter(i)).padding(Auto),
20 ))
21 })
22 }),
23 format!("total: {}", cx[counters].sum_counters()).padding(Auto),
24 button("add counter", move |cx| cx[counters].add_counter()).padding(Auto),
25 ))
26 }));
27}