tasks initial impl (still working on task_on trait method)

This commit is contained in:
2026-01-03 16:26:23 -05:00
parent 5da1e9e767
commit 59901b6580
13 changed files with 231 additions and 26 deletions

View File

@@ -2,9 +2,11 @@ use crate::{
Event, EventCtx, EventLike, EventManager, HasUi, IdLike, Widget, WidgetEventFn, WidgetRef,
};
pub trait HasEvents: Sized + HasUi + 'static {
pub trait HasState: 'static {
type State;
}
pub trait HasEvents: Sized + HasUi + HasState {
fn events(&self) -> &EventManager<Self>;
fn events_mut(&mut self) -> &mut EventManager<Self>;
@@ -18,7 +20,7 @@ pub trait HasEvents: Sized + HasUi + 'static {
}
}
pub trait RunEvents: HasEvents + 'static {
pub trait RunEvents: HasEvents {
fn run_event<E: EventLike>(
&mut self,
id: impl IdLike,
@@ -29,4 +31,4 @@ pub trait RunEvents: HasEvents + 'static {
f(EventCtx { state, data }, self)
}
}
impl<T: HasEvents + 'static> RunEvents for T {}
impl<T: HasEvents> RunEvents for T {}

View File

@@ -169,3 +169,5 @@ fn null_ptr<W: ?Sized>() -> *const W {
unsafe { std::mem::transmute_copy(&[0usize; 1]) }
}
}
unsafe impl<W: ?Sized> Send for WidgetRef<W> {}