From 493b0693c5be8429f98f93bc30bc98f96568bc2c Mon Sep 17 00:00:00 2001 From: Exotik850 Date: Tue, 12 Dec 2023 13:15:41 -0600 Subject: [PATCH] Put channels back in hook --- packages/hooks/src/use_coroutine.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/hooks/src/use_coroutine.rs b/packages/hooks/src/use_coroutine.rs index 8d2212162..f2577b90c 100644 --- a/packages/hooks/src/use_coroutine.rs +++ b/packages/hooks/src/use_coroutine.rs @@ -69,9 +69,11 @@ where G: FnOnce(UnboundedReceiver) -> F, F: Future + 'static, { - let (tx, rx) = futures_channel::mpsc::unbounded(); - let task = cx.push_future(init(rx)); - cx.use_hook(|| cx.provide_context(Coroutine { tx, task })) + cx.use_hook(|| { + let (tx, rx) = futures_channel::mpsc::unbounded(); + let task = cx.push_future(init(rx)); + cx.provide_context(Coroutine { tx, task }) + }) } /// Get a handle to a coroutine higher in the tree