comment out element triggers

This commit is contained in:
griffi-gh 2024-03-21 22:26:50 +01:00
parent d526928d9b
commit 7ae72b7a41

View file

@ -1,4 +1,4 @@
use crate::element::UiElement;
//use crate::element::UiElement;
use super::{Signal, SignalStore};
#[allow(clippy::complexity)]
@ -30,32 +30,34 @@ impl<T> SignalTriggerArg<T> {
(self.0)(s, x);
}
}
#[allow(clippy::complexity)]
pub struct SignalTriggerElement<E: UiElement>(Box<dyn Fn(&mut SignalStore, &mut E)>);
impl<E: UiElement> SignalTriggerElement<E> {
pub fn new<S: Signal, F: Fn(&mut E) -> S + 'static>(f: F) -> Self {
Self(Box::new(move |s: &mut SignalStore, e: &mut E| {
s.add::<S>(f(e));
}))
}
pub fn fire(&self, s: &mut SignalStore, e: &mut E) {
(self.0)(s, e);
}
}
// #[allow(clippy::complexity)]
// pub struct SignalTriggerElement<E: UiElement>(Box<dyn Fn(&mut SignalStore, &mut E)>);
#[allow(clippy::complexity)]
pub struct SignalTriggerElementArg<E: UiElement, T>(Box<dyn Fn(&mut SignalStore, &mut E, T)>);
// impl<E: UiElement> SignalTriggerElement<E> {
// pub fn new<S: Signal, F: Fn(&mut E) -> S + 'static>(f: F) -> Self {
// Self(Box::new(move |s: &mut SignalStore, e: &mut E| {
// s.add::<S>(f(e));
// }))
// }
impl<E: UiElement, T> SignalTriggerElementArg<E, T> {
pub fn new<S: Signal, F: Fn(T, &mut E) -> S + 'static>(f: F) -> Self {
Self(Box::new(move |s: &mut SignalStore, e: &mut E, x| {
s.add::<S>(f(x, e));
}))
}
// pub fn fire(&self, s: &mut SignalStore, e: &mut E) {
// (self.0)(s, e);
// }
// }
pub fn fire(&self, s: &mut SignalStore, e: &mut E, x: T) {
(self.0)(s, e, x);
}
}
// #[allow(clippy::complexity)]
// pub struct SignalTriggerElementArg<E: UiElement, T>(Box<dyn Fn(&mut SignalStore, &mut E, T)>);
// impl<E: UiElement, T> SignalTriggerElementArg<E, T> {
// pub fn new<S: Signal, F: Fn(T, &mut E) -> S + 'static>(f: F) -> Self {
// Self(Box::new(move |s: &mut SignalStore, e: &mut E, x| {
// s.add::<S>(f(x, e));
// }))
// }
// pub fn fire(&self, s: &mut SignalStore, e: &mut E, x: T) {
// (self.0)(s, e, x);
// }
// }