use std::rc::Rc;
use crate::Context;
use crate::effect::EffectHandle;
use crate::slot::SlotHandle;
pub struct SignalHandle<T> {
pub(crate) slot: SlotHandle<T>,
pub(crate) effect: EffectHandle,
}
impl<T> SignalHandle<T> {
pub(crate) fn new(slot: SlotHandle<T>, effect: EffectHandle) -> Self {
Self { slot, effect }
}
pub fn get(&self, ctx: &Context) -> T
where
T: Clone + 'static,
{
ctx.get_signal(self)
}
pub fn get_rc(&self, ctx: &Context) -> Rc<T>
where
T: 'static,
{
ctx.get_signal_rc(self)
}
pub fn dispose(&self, ctx: &Context) {
ctx.dispose_signal(self);
}
pub fn is_active(&self, ctx: &Context) -> bool {
ctx.is_signal_active(self)
}
}
impl<T> Clone for SignalHandle<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for SignalHandle<T> {}