separate state from rsc

This commit is contained in:
2026-01-01 22:18:08 -05:00
parent 462c0e6416
commit 5da1e9e767
22 changed files with 373 additions and 492 deletions

View File

@@ -3,20 +3,20 @@ use crate::prelude::*;
pub mod eventable {
use super::*;
widget_trait! {
pub trait Eventable<State: HasEvents + StateLike<State> + 'static>;
pub trait Eventable<Rsc: HasEvents + 'static>;
fn on<E: EventLike>(
self,
event: E,
f: impl for<'a> WidgetEventFn<State::State, <E::Event as Event>::Data<'a>, WL::Widget>,
) -> impl WidgetIdFn<State, WL::Widget> {
f: impl for<'a> WidgetEventFn<Rsc, <E::Event as Event>::Data<'a>, WL::Widget>,
) -> impl WidgetIdFn<Rsc, WL::Widget> {
move |state| {
let id = self.add(state);
state.register_event(id, event.into_event(), move |ctx| {
state.register_event(id, event.into_event(), move |ctx, rsc| {
f(&mut EventIdCtx {
widget: id,
state: ctx.state,
data: ctx.data,
});
}, rsc);
});
id
}