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