Rename Handle to Model

This commit is contained in:
Antonio Scandurra 2023-10-30 19:44:01 +01:00
parent 14d24a9ac6
commit 1a54ac0d69
32 changed files with 11195 additions and 482 deletions

View file

@ -1,5 +1,5 @@
use crate::{
AnyWindowHandle, AppContext, AsyncAppContext, Context, Executor, Handle, MainThread,
AnyWindowHandle, AppContext, AsyncAppContext, Context, Executor, MainThread, Model,
ModelContext, Result, Task, TestDispatcher, TestPlatform, WindowContext,
};
use parking_lot::Mutex;
@ -12,24 +12,24 @@ pub struct TestAppContext {
}
impl Context for TestAppContext {
type EntityContext<'a, T> = ModelContext<'a, T>;
type ModelContext<'a, T> = ModelContext<'a, T>;
type Result<T> = T;
fn entity<T: 'static>(
fn build_model<T: 'static>(
&mut self,
build_entity: impl FnOnce(&mut Self::EntityContext<'_, T>) -> T,
) -> Self::Result<Handle<T>>
build_model: impl FnOnce(&mut Self::ModelContext<'_, T>) -> T,
) -> Self::Result<Model<T>>
where
T: 'static + Send,
{
let mut lock = self.app.lock();
lock.entity(build_entity)
lock.build_model(build_model)
}
fn update_entity<T: 'static, R>(
&mut self,
handle: &Handle<T>,
update: impl FnOnce(&mut T, &mut Self::EntityContext<'_, T>) -> R,
handle: &Model<T>,
update: impl FnOnce(&mut T, &mut Self::ModelContext<'_, T>) -> R,
) -> Self::Result<R> {
let mut lock = self.app.lock();
lock.update_entity(handle, update)