From b6df1e7e4141610f730b5324b122f1fa993fdae8 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 28 May 2021 00:45:30 +0200 Subject: [PATCH] projection: define channel type per argument type --- nested/src/projection.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/nested/src/projection.rs b/nested/src/projection.rs index f33b9f9..8f78778 100644 --- a/nested/src/projection.rs +++ b/nested/src/projection.rs @@ -2,7 +2,8 @@ use { std::{ cmp::{max}, any::Any, - sync::{Arc, Weak} + sync::{Arc, Weak}, + hash::Hash }, std::sync::RwLock, crate::{ @@ -14,7 +15,7 @@ use { channel::{ ChannelSender, ChannelReceiver, ChannelData, - channel + set_channel } }, singleton::{SingletonView}, @@ -53,7 +54,7 @@ impl ProjectionHelper

{ notify: impl Fn(&mut P, &()) + Send + Sync + 'static ) -> Arc>>>> { self.update_hooks.write().unwrap().push(Arc::new(port.0.clone())); - port.add_observer(self.new_arg(notify)); + port.add_observer(self.new_arg(notify, set_channel())); port.get_view_arc() } @@ -63,31 +64,34 @@ impl ProjectionHelper

{ notify: impl Fn(&mut P, &usize) + Send + Sync + 'static ) -> Arc>>>> { self.update_hooks.write().unwrap().push(Arc::new(port.0.clone())); - port.add_observer(self.new_arg(notify)); + port.add_observer(self.new_arg(notify, set_channel())); port.get_view_arc() } - pub fn new_index_arg( + pub fn new_index_arg( &mut self, port: OuterViewPort>, notify: impl Fn(&mut P, &Key) + Send + Sync + 'static ) -> Arc>>>> { self.update_hooks.write().unwrap().push(Arc::new(port.0.clone())); - let arg = self.new_arg(notify); + let arg = self.new_arg(notify, set_channel()); port.add_observer(arg); port.get_view_arc() } pub fn new_arg< - V: View + ?Sized + 'static + V: View + ?Sized + 'static, + D: ChannelData + 'static >( &mut self, - notify: impl Fn(&mut P, &V::Msg) + Send + Sync + 'static - ) -> Arc>>> - where V::Msg: Send + Sync + notify: impl Fn(&mut P, &V::Msg) + Send + Sync + 'static, + (tx, rx): (ChannelSender, ChannelReceiver) + ) + -> Arc>> + where V::Msg: Send + Sync, + D::IntoIter: Send + Sync + 'static { - let (tx, rx) = channel::>(); let arg = Arc::new(RwLock::new( ProjectionArg { src: None,