use super::*;
use std::{cell::RefCell, rc::Rc};
pub struct ComponentHandle {
state: Rc<RefCell<ComponentState>>,
}
impl ComponentHandle {
pub(crate) 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()
}
}