From 78c5ffcdbe58dfeb44815b87f103f32f76808a4d Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Wed, 11 Aug 2021 18:08:53 +0200 Subject: [PATCH] small notification fixes --- nested/src/core/port.rs | 1 + nested/src/vec/vec2seq.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nested/src/core/port.rs b/nested/src/core/port.rs index 34445c5..3d860bf 100644 --- a/nested/src/core/port.rs +++ b/nested/src/core/port.rs @@ -50,6 +50,7 @@ where V::Msg: Clone { } pub fn add_observer(&self, observer: Arc>>) { + self.update(); self.cast.write().unwrap().add_observer(Arc::downgrade(&observer)); observer.write().unwrap().reset(self.view.read().unwrap().clone()); } diff --git a/nested/src/vec/vec2seq.rs b/nested/src/vec/vec2seq.rs index 0fa7372..7104c37 100644 --- a/nested/src/vec/vec2seq.rs +++ b/nested/src/vec/vec2seq.rs @@ -43,15 +43,15 @@ where T: Clone + Send + Sync + 'static { fn reset(&mut self, view: Option>>>) { let old_len = self.cur_len; self.data = view; - self.cur_len = 0; - /* + let new_len = if let Some(data) = self.data.as_ref() { data.read().unwrap().len() } else { 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) {