Add toggle
This commit is contained in:
2 files changed
+8
-1
No files matched your search
@@ -262,6 +262,13 @@ impl<T: Clone + 'static> Signal<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Signal<bool> {
|
||||
/// Invert the boolean value of the signal. This will trigger an update on all subscribers.
|
||||
pub fn toggle(&self) {
|
||||
self.set(!self.value());
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> PartialEq for Signal<T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.inner == other.inner
|
||||
|
||||
Reference in new issue
Block a user