add a map method to signal
This commit is contained in:
1 parent
3578f03f4f
commit
7ea868bd08
1 file changed
+6
@@ -1,3 +1,4 @@
|
||||
use crate::SignalMap;
|
||||
use std::{
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
ops::{Deref, DerefMut},
|
||||
@@ -252,6 +253,11 @@ impl<T: 'static> Signal<T> {
|
||||
let mut write = self.write();
|
||||
f(&mut *write)
|
||||
}
|
||||
|
||||
/// Map the signal to a new type.
|
||||
pub fn map<O>(self, f: fn(&T) -> &O) -> SignalMap<T, O> {
|
||||
SignalMap::new(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + 'static> Signal<T> {
|
||||
|
||||
Reference in new issue
Block a user