port: add_[observer|reset]_fn return the observer object instead of view
now because we use Weak in ObserverBroadcast, we need at least one Arc somewhere else
This commit is contained in:
parent
5007fdea3c
commit
ceb0a8a5a9
1 changed files with 8 additions and 6 deletions
|
@ -111,15 +111,17 @@ impl<V: View + ?Sized + 'static> OuterViewPort<V> {
|
|||
self.get_view_arc()
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn add_reset_fn(&self, reset: impl Fn(Option<Arc<V>>) + Send + Sync + 'static) -> Arc<RwLock<Option<Arc<V>>>> {
|
||||
self.add_observer(Arc::new(ResetFnObserver::new(reset)))
|
||||
pub fn add_reset_fn<F: Fn(Option<Arc<V>>) + Send + Sync + 'static>(&self, reset: F) -> Arc<RwLock<ResetFnObserver<V, F>>> {
|
||||
let obs = Arc::new(RwLock::new(ResetFnObserver::new(reset)));
|
||||
self.add_observer(obs.clone());
|
||||
obs
|
||||
}
|
||||
|
||||
pub fn add_notify_fn(&self, notify: impl Fn(&V::Msg) + Send + Sync + 'static) -> Arc<RwLock<Option<Arc<V>>>> {
|
||||
self.add_observer(Arc::new(NotifyFnObserver::new(notify)))
|
||||
pub fn add_notify_fn<F: Fn(&V::Msg) + Send + Sync + 'static>(&self, notify: F) -> Arc<RwLock<NotifyFnObserver<V, F>>> {
|
||||
let obs = Arc::new(RwLock::new(NotifyFnObserver::new(notify)));
|
||||
self.add_observer(obs.clone());
|
||||
obs
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue