use crate::api; use crate::config::Config; use crate::models::helper::*; #[derive(Debug)] pub struct ObserversT { config: Config, } impl Model for ObserversT { type FetchData = api::ObserverList; const NAME: &'static str = "Observers"; fn refresh(sr: &ModelHandle) -> Option { let sref = sr.clone(); let sd = sr.data(); sr.service().api_observers(&sd.config, move |result| { sref.set_received(result); }) } } #[derive(Clone, PartialEq, Eq, Debug)] pub struct Observers(pub(super) ModelHandle); impl std::ops::Deref for Observers { type Target = ModelHandle; fn deref(&self) -> &Self::Target { &self.0 } } impl Observers { pub fn new(config: Config) -> Self { Self(ModelHandle::new( ObserversT { config }, (), )) } pub(super) fn new_shared(config: Config, base: ModelBase) -> Self { Self(ModelHandle::new( ObserversT { config }, base, )) } }