Enable tester feature in websocket example

This commit is contained in:
Héctor Ramón Jiménez 2025-06-03 09:54:14 +02:00
parent 1821dc7ff0
commit 9cd1a93e5a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
5 changed files with 44 additions and 16 deletions

View file

@ -9,6 +9,7 @@ use crate::core::alignment::Horizontal::Right;
use crate::core::border;
use crate::core::window;
use crate::core::{Element, Event, Size, Theme};
use crate::futures::Subscription;
use crate::futures::futures::channel::mpsc;
use crate::icon;
use crate::program;
@ -62,8 +63,12 @@ impl<P: Program + 'static> Tester<P> {
}
}
pub fn is_idle(&self) -> bool {
matches!(self.state, State::Idle)
}
pub fn is_busy(&self) -> bool {
matches!(self.state, State::Idle | State::Playing { .. })
matches!(self.state, State::Recording { .. } | State::Playing { .. })
}
pub fn update(&mut self, program: &P, message: Message) -> Task<Tick<P>> {
@ -160,6 +165,15 @@ impl<P: Program + 'static> Tester<P> {
}
}
pub fn subscription(&self, program: &P) -> Subscription<Tick<P>> {
match &self.state {
State::Idle | State::Playing { .. } => Subscription::none(),
State::Recording { state } => {
program.subscription(state).map(Tick::Program)
}
}
}
pub fn view<'a, T: 'static>(
&'a self,
program: &P,