yewlish-utils 0.1.12

Common utils for yewlish component set
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use yew::Callback;

#[must_use]
pub fn combine_handlers<T: Clone + 'static>(
    a: Option<Callback<T>>,
    b: Option<Callback<T>>,
) -> Callback<T> {
    Callback::from(move |event: T| {
        if let Some(a) = a.clone() {
            a.emit(event.clone());
        }

        if let Some(b) = b.clone() {
            b.emit(event);
        }
    })
}