mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-12 23:57:09 +00:00
impl UntrackedGettableSignal
for MaybeSignal
This commit is contained in:
parent
3d88227bac
commit
00b6b39ee0
1 changed files with 22 additions and 0 deletions
|
@ -288,6 +288,28 @@ where
|
|||
Dynamic(Signal<T>),
|
||||
}
|
||||
|
||||
impl<T> UntrackedGettableSignal<T> for MaybeSignal<T>
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
fn get_untracked(&self) -> T
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
match self {
|
||||
Self::Static(t) => t.clone(),
|
||||
Self::Dynamic(s) => s.get_untracked(),
|
||||
}
|
||||
}
|
||||
|
||||
fn with_untracked<O>(&self, f: impl FnOnce(&T) -> O) -> O {
|
||||
match self {
|
||||
Self::Static(t) => f(t),
|
||||
Self::Dynamic(s) => s.with_untracked(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> MaybeSignal<T>
|
||||
where
|
||||
T: 'static,
|
||||
|
|
Loading…
Reference in a new issue