small notification fixes
This commit is contained in:
parent
316b332d4a
commit
78c5ffcdbe
2 changed files with 5 additions and 4 deletions
|
@ -50,6 +50,7 @@ where V::Msg: Clone {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_observer(&self, observer: Arc<RwLock<dyn Observer<V>>>) {
|
pub fn add_observer(&self, observer: Arc<RwLock<dyn Observer<V>>>) {
|
||||||
|
self.update();
|
||||||
self.cast.write().unwrap().add_observer(Arc::downgrade(&observer));
|
self.cast.write().unwrap().add_observer(Arc::downgrade(&observer));
|
||||||
observer.write().unwrap().reset(self.view.read().unwrap().clone());
|
observer.write().unwrap().reset(self.view.read().unwrap().clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,15 +43,15 @@ where T: Clone + Send + Sync + 'static {
|
||||||
fn reset(&mut self, view: Option<Arc<RwLock<Vec<T>>>>) {
|
fn reset(&mut self, view: Option<Arc<RwLock<Vec<T>>>>) {
|
||||||
let old_len = self.cur_len;
|
let old_len = self.cur_len;
|
||||||
self.data = view;
|
self.data = view;
|
||||||
self.cur_len = 0;
|
let new_len =
|
||||||
/*
|
|
||||||
if let Some(data) = self.data.as_ref() {
|
if let Some(data) = self.data.as_ref() {
|
||||||
data.read().unwrap().len()
|
data.read().unwrap().len()
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
self.cast.notify_each(0 .. std::cmp::max(old_len, self.cur_len));
|
self.cur_len = new_len;
|
||||||
|
self.cast.notify_each(0 .. std::cmp::max(old_len, new_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify(&mut self, diff: &VecDiff<T>) {
|
fn notify(&mut self, diff: &VecDiff<T>) {
|
||||||
|
|
Loading…
Reference in a new issue