fix use hooks with impl signals
This commit is contained in:
1 parent
51d7133ca5
commit
c51badf07b
3 files changed
+6
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
use dioxus_core::prelude::{consume_context, provide_context, spawn, use_hook};
|
||||
use dioxus_core::Task;
|
||||
use dioxus_signals::{CopyValue, Signal};
|
||||
use dioxus_signals::*;
|
||||
pub use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||
use std::future::Future;
|
||||
|
||||
@@ -71,7 +71,7 @@ where
|
||||
G: FnOnce(UnboundedReceiver<M>) -> F,
|
||||
F: Future<Output = ()> + 'static,
|
||||
{
|
||||
let coroutine = use_hook(|| {
|
||||
let mut coroutine = use_hook(|| {
|
||||
provide_context(Coroutine {
|
||||
needs_regen: Signal::new(true),
|
||||
tx: CopyValue::new(None),
|
||||
@@ -81,12 +81,12 @@ where
|
||||
|
||||
// We do this here so we can capture data with FnOnce
|
||||
// this might not be the best API
|
||||
if *coroutine.needs_regen.read() {
|
||||
if *coroutine.needs_regen.peek() {
|
||||
let (tx, rx) = futures_channel::mpsc::unbounded();
|
||||
let task = spawn(init(rx));
|
||||
coroutine.tx.set(Some(tx));
|
||||
coroutine.task.set(Some(task));
|
||||
coroutine.needs_regen.set_untracked(false);
|
||||
coroutine.needs_regen.set(false);
|
||||
}
|
||||
|
||||
coroutine
|
||||
|
||||
@@ -3,7 +3,7 @@ use dioxus_core::{
|
||||
prelude::{spawn, use_hook},
|
||||
ScopeState, Task,
|
||||
};
|
||||
use dioxus_signals::{use_effect, use_signal, Effect, Signal};
|
||||
use dioxus_signals::*;
|
||||
use futures_util::{future, pin_mut, FutureExt};
|
||||
use std::{any::Any, cell::Cell, future::Future, pin::Pin, rc::Rc, sync::Arc, task::Poll};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use dioxus_core::{
|
||||
prelude::{spawn, use_hook},
|
||||
ScopeState, Task,
|
||||
};
|
||||
use dioxus_signals::{use_effect, use_signal, Effect, Signal};
|
||||
use dioxus_signals::*;
|
||||
use futures_util::{future, pin_mut, FutureExt};
|
||||
use std::{any::Any, cell::Cell, future::Future, pin::Pin, rc::Rc, sync::Arc, task::Poll};
|
||||
|
||||
|
||||
Reference in new issue
Block a user