simplify the readable and writable traits a bit
This commit is contained in:
1 parent
c172914b21
commit
6bc0332052
7 files changed
+20
-49
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use crate::{read::Readable, ReadableRef, Signal, SignalData};
|
||||
use crate::{read::Readable, Signal, SignalData};
|
||||
use std::{mem::MaybeUninit, ops::Deref};
|
||||
|
||||
use dioxus_core::{prelude::IntoAttributeValue, ScopeId};
|
||||
@@ -41,7 +41,7 @@ impl<T: 'static, S: Storage<SignalData<T>>> ReadOnlySignal<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S: Storage<SignalData<T>>> ReadableRef for ReadOnlySignal<T, S> {
|
||||
impl<T, S: Storage<SignalData<T>>> Readable<T> for ReadOnlySignal<T, S> {
|
||||
type Ref<R: ?Sized + 'static> = S::Ref<R>;
|
||||
|
||||
fn map_ref<I, U: ?Sized, F: FnOnce(&I) -> &U>(ref_: Self::Ref<I>, f: F) -> Self::Ref<U> {
|
||||
@@ -54,9 +54,7 @@ impl<T, S: Storage<SignalData<T>>> ReadableRef for ReadOnlySignal<T, S> {
|
||||
) -> Option<Self::Ref<U>> {
|
||||
S::try_map(ref_, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S: Storage<SignalData<T>>> Readable<T> for ReadOnlySignal<T, S> {
|
||||
/// Get the current value of the signal. This will subscribe the current scope to the signal. If you would like to read the signal without subscribing to it, you can use [`Self::peek`] instead.
|
||||
///
|
||||
/// If the signal has been dropped, this will panic.
|
||||
@@ -72,6 +70,7 @@ impl<T, S: Storage<SignalData<T>>> Readable<T> for ReadOnlySignal<T, S> {
|
||||
self.inner.peek()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> IntoAttributeValue for ReadOnlySignal<T>
|
||||
where
|
||||
T: Clone + IntoAttributeValue,
|
||||
|
||||
Reference in new issue
Block a user