Checkpoint
This commit is contained in:
parent
77b9a7aa5a
commit
1c70ca2214
3 changed files with 22 additions and 2 deletions
|
@ -143,6 +143,14 @@ impl<'a, 'w> WindowContext<'a, 'w> {
|
|||
AsyncWindowContext::new(self.app.to_async(), self.window.handle)
|
||||
}
|
||||
|
||||
pub fn on_next_frame(&mut self, f: impl FnOnce(&mut WindowContext) + Send + 'static) {
|
||||
let cx = self.to_async();
|
||||
let display_id = self.window.display_id;
|
||||
self.display_linker.on_next_frame(display_id, move |_, _| {
|
||||
cx.update(f).ok();
|
||||
});
|
||||
}
|
||||
|
||||
pub fn spawn<Fut, R>(
|
||||
&mut self,
|
||||
f: impl FnOnce(AnyWindowHandle, AsyncWindowContext) -> Fut + Send + 'static,
|
||||
|
@ -581,6 +589,15 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {
|
|||
self.entities.weak_handle(self.entity_id)
|
||||
}
|
||||
|
||||
pub fn on_next_frame(&mut self, f: impl FnOnce(&mut S, &mut ViewContext<S>) + Send + 'static) {
|
||||
let mut cx = self.to_async();
|
||||
let entity = self.handle();
|
||||
let display_id = self.window.display_id;
|
||||
self.display_linker.on_next_frame(display_id, move |_, _| {
|
||||
entity.update(&mut cx, f).ok();
|
||||
});
|
||||
}
|
||||
|
||||
pub fn observe<E: Send + Sync + 'static>(
|
||||
&mut self,
|
||||
handle: &Handle<E>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue