use super::{ConnectionHandle, ConnectionScope, Priority, 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_with_priority<F>(&self, mut slot: F, priority: Priority) -> ConnectionHandle
where
F: FnMut() + Send + Sync + 'static,
{
self.inner.connect_with_priority(move |_| slot(), priority)
}
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 block(&self, handle: ConnectionHandle) -> bool {
self.inner.block(handle)
}
pub fn unblock(&self, handle: ConnectionHandle) -> bool {
self.inner.unblock(handle)
}
pub fn is_blocked(&self, handle: ConnectionHandle) -> Option<bool> {
self.inner.is_blocked(handle)
}
pub fn set_priority(&self, handle: ConnectionHandle, priority: Priority) -> bool {
self.inner.set_priority(handle, priority)
}
pub fn is_connected(&self, handle: ConnectionHandle) -> bool {
self.inner.is_connected(handle)
}
pub fn is_empty(&self) -> bool {
self.inner.slot_count() == 0
}
pub fn clear(&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>;