Change context api to panic with nice error message

This commit is contained in:
Jonathan Kelley committed 2024-01-15 18:02:58 -08:00
1 parent ee5020c41f
commit 14651a3573
19 files changed
+96 -69

No files matched your search

+5 -1
View File
@@ -96,7 +96,7 @@ where
///
/// See the docs for [`use_coroutine`] for more details.
#[must_use]
pub fn use_coroutine_handle<M: 'static>() -> Option<Coroutine<M>> {
pub fn use_coroutine_handle<M: 'static>() -> Coroutine<M> {
use_hook(|| consume_context::<Coroutine<M>>())
}
@@ -118,6 +118,10 @@ impl<T> Coroutine<T> {
let _ = self.tx.read().as_ref().unwrap().unbounded_send(msg);
}
pub fn tx(&self) -> UnboundedSender<T> {
self.tx.read().as_ref().unwrap().clone()
}
/// Restart this coroutine
///
/// Forces the component to re-render, which will re-invoke the coroutine.