1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use super::*;
use std::{cell::RefCell, rc::Rc};
pub struct ComponentHandle {
state: Rc<RefCell<ComponentState>>,
}
impl ComponentHandle {
pub(super) fn new(state: Rc<RefCell<ComponentState>>) -> Self {
Self { state }
}
pub fn pause(&self) {
*self.state.borrow_mut() = ComponentState::Paused;
}
pub fn resume(&self) {
*self.state.borrow_mut() = ComponentState::Working;
}
pub fn remove(self) {
*self.state.borrow_mut() = ComponentState::Removed;
}
pub fn state(&self) -> ComponentState {
*self.state.borrow()
}
}