use super::{ConnectionHandle, ConnectionScope, Signal};
#[derive(Clone, Default)]
pub struct GenericSignal {
inner: Signal<()>,
}
impl GenericSignal {
pub fn new() -> Self {
Self { inner: Signal::new() }
}
pub fn connect<F>(&self, mut slot: F) -> ConnectionHandle
where
F: FnMut() + Send + Sync + 'static,
{
self.inner.connect(move |_| slot())
}
pub fn connect_once<F>(&self, mut slot: F) -> ConnectionHandle
where
F: FnMut() + Send + Sync + 'static,
{
self.inner.connect_once(move |_| slot())
}
pub fn connect_scoped<F>(&self, owner: &ConnectionScope, mut slot: F) -> ConnectionHandle
where
F: FnMut() + Send + Sync + 'static,
{
self.inner.connect_scoped(owner, move |_| slot())
}
pub fn connect_once_scoped<F>(&self, owner: &ConnectionScope, mut slot: F) -> ConnectionHandle
where
F: FnMut() + Send + Sync + 'static,
{
self.inner.connect_once_scoped(owner, move |_| slot())
}
pub fn disconnect(&self, handle: ConnectionHandle) -> bool {
self.inner.disconnect(handle)
}
pub fn disconnect_all(&self) {
self.inner.disconnect_all();
}
pub fn emit(&self) {
self.inner.emit(())
}
pub fn slot_count(&self) -> usize {
self.inner.slot_count()
}
}
pub type Signal1<T> = Signal<T>;