added Signal::default method

This commit is contained in:
Jose Quesada 2023-01-06 08:34:15 -06:00
parent 7631ce3b09
commit c9ac4ed2b5

View file

@ -169,6 +169,15 @@ where
SignalTypes::DerivedSignal(_, s) => s.with(|s| s()),
}
}
/// Creates a signal that yields the default value of `T` when
/// you call `.get()` or `signal()`.
pub fn default(cx: Scope) -> Self
where
T: Default,
{
Self::derive(cx, || Default::default())
}
}
impl<T> From<ReadSignal<T>> for Signal<T> {