|
@@ -1,6 +1,6 @@
|
|
use crate::{
|
|
use crate::{
|
|
read::Readable, write::Writable, Effect, EffectInner, GlobalMemo, GlobalSignal, MappedSignal,
|
|
read::Readable, write::Writable, Effect, EffectInner, GlobalMemo, GlobalSignal, MappedSignal,
|
|
- ReadOnlySignal, ReadableRef, WritableRef,
|
|
|
|
|
|
+ ReadOnlySignal,
|
|
};
|
|
};
|
|
use std::{
|
|
use std::{
|
|
any::Any,
|
|
any::Any,
|
|
@@ -399,7 +399,7 @@ impl<T: 'static, S: Storage<SignalData<T>>> Signal<T, S> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-impl<T, S: Storage<SignalData<T>>> ReadableRef for Signal<T, S> {
|
|
|
|
|
|
+impl<T, S: Storage<SignalData<T>>> Readable<T> for Signal<T, S> {
|
|
type Ref<R: ?Sized + 'static> = S::Ref<R>;
|
|
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> {
|
|
fn map_ref<I, U: ?Sized, F: FnOnce(&I) -> &U>(ref_: Self::Ref<I>, f: F) -> Self::Ref<U> {
|
|
@@ -412,9 +412,7 @@ impl<T, S: Storage<SignalData<T>>> ReadableRef for Signal<T, S> {
|
|
) -> Option<Self::Ref<U>> {
|
|
) -> Option<Self::Ref<U>> {
|
|
S::try_map(ref_, f)
|
|
S::try_map(ref_, f)
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
|
|
-impl<T, S: Storage<SignalData<T>>> Readable<T> for Signal<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.
|
|
/// 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.
|
|
/// If the signal has been dropped, this will panic.
|
|
@@ -458,7 +456,7 @@ impl<T, S: Storage<SignalData<T>>> Readable<T> for Signal<T, S> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-impl<T: 'static, S: Storage<SignalData<T>>> WritableRef for Signal<T, S> {
|
|
|
|
|
|
+impl<T: 'static, S: Storage<SignalData<T>>> Writable<T> for Signal<T, S> {
|
|
type Mut<R: ?Sized + 'static> = Write<R, S>;
|
|
type Mut<R: ?Sized + 'static> = Write<R, S>;
|
|
|
|
|
|
fn map_mut<I, U: ?Sized + 'static, F: FnOnce(&mut I) -> &mut U>(
|
|
fn map_mut<I, U: ?Sized + 'static, F: FnOnce(&mut I) -> &mut U>(
|
|
@@ -474,9 +472,7 @@ impl<T: 'static, S: Storage<SignalData<T>>> WritableRef for Signal<T, S> {
|
|
) -> Option<Self::Mut<U>> {
|
|
) -> Option<Self::Mut<U>> {
|
|
Write::filter_map(ref_, f)
|
|
Write::filter_map(ref_, f)
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
|
|
-impl<T: 'static, S: Storage<SignalData<T>>> Writable<T> for Signal<T, S> {
|
|
|
|
#[track_caller]
|
|
#[track_caller]
|
|
fn try_write(&self) -> Result<Self::Mut<T>, generational_box::BorrowMutError> {
|
|
fn try_write(&self) -> Result<Self::Mut<T>, generational_box::BorrowMutError> {
|
|
self.inner.try_write().map(|inner| {
|
|
self.inner.try_write().map(|inner| {
|