WithDynText is now implemented for QuerySignal and WithDefault.

This commit is contained in:
2024-02-20 03:22:11 +00:00
parent 95d86209a2
commit 8dcd2dce09

View File

@@ -3,7 +3,8 @@
// Imports
use {
crate::ObjectAttachEffect,
dynatos_reactive::{Derived, Effect, Signal, SignalWith},
dynatos_reactive::{Derived, Effect, Signal, SignalWith, WithDefault},
dynatos_router::QuerySignal,
dynatos_util::{TryOrReturnExt, WeakRef},
};
@@ -128,3 +129,26 @@ where
self.with(|text| text.with_text(f))
}
}
impl<T> WithDynText for QuerySignal<T>
where
T: WithDynText,
{
fn with_text<F, O>(&self, f: F) -> O
where
F: FnOnce(Option<&str>) -> O,
{
self.with(|text| text.with_text(f))
}
}
impl<S, T> WithDynText for WithDefault<S, T>
where
S: SignalWith<Value = Option<T>>,
T: WithDynText,
{
fn with_text<F, O>(&self, f: F) -> O
where
F: FnOnce(Option<&str>) -> O,
{
self.with(|text| text.with_text(f))
}
}