Web: set control flow strategies on EventLoop (#3740)

This commit is contained in:
daxpedda
2024-06-20 22:56:08 +02:00
committed by Kirill Chibisov
parent 3d7d766182
commit a974640a66
2 changed files with 31 additions and 0 deletions

View File

@@ -190,6 +190,20 @@ pub trait EventLoopExtWebSys {
fn spawn<F>(self, event_handler: F)
where
F: 'static + FnMut(Event<Self::UserEvent>, &ActiveEventLoop);
/// Sets the strategy for [`ControlFlow::Poll`].
///
/// See [`PollStrategy`].
///
/// [`ControlFlow::Poll`]: crate::event_loop::ControlFlow::Poll
fn set_poll_strategy(&self, strategy: PollStrategy);
/// Gets the strategy for [`ControlFlow::Poll`].
///
/// See [`PollStrategy`].
///
/// [`ControlFlow::Poll`]: crate::event_loop::ControlFlow::Poll
fn poll_strategy(&self) -> PollStrategy;
}
impl<T> EventLoopExtWebSys for EventLoop<T> {
@@ -207,6 +221,14 @@ impl<T> EventLoopExtWebSys for EventLoop<T> {
{
self.event_loop.spawn(event_handler)
}
fn set_poll_strategy(&self, strategy: PollStrategy) {
self.event_loop.set_poll_strategy(strategy);
}
fn poll_strategy(&self) -> PollStrategy {
self.event_loop.poll_strategy()
}
}
pub trait ActiveEventLoopExtWebSys {