euv_core/event/handler/struct.rs
1use super::*;
2
3/// A wrapper around an event callback.
4///
5/// Stores the event name and a shared reference to the callback closure.
6/// Uses `Rc<UnsafeCell<>>` instead of `Rc<RefCell<>>` to avoid runtime
7/// borrow checking overhead in the single-threaded WASM context.
8/// The `Rc` provides automatic memory management (freed when last reference drops).
9#[derive(Clone, CustomDebug, Data, New)]
10#[new(pub(crate))]
11pub struct NativeEventHandler {
12 /// The name of the event (e.g., "click", "input").
13 #[get(type(copy), pub(crate))]
14 #[get_mut(pub(crate))]
15 #[set(pub(crate))]
16 pub(crate) event_name: &'static str,
17 /// Shared reference to the callback closure.
18 /// `UnsafeCell` allows mutable access without RefCell overhead.
19 /// Safety: only accessed from the main thread in WASM single-threaded context.
20 #[debug(skip)]
21 #[get(pub(crate))]
22 #[get_mut(pub(crate))]
23 #[set(pub(crate))]
24 pub(crate) callback: SharedEventCallback,
25}