瀏覽代碼

fix use hooks with impl signals

Evan Almloff 1 年之前
父節點
當前提交
c51badf07b
共有 3 個文件被更改,包括 6 次插入6 次删除
  1. 4 4
      packages/hooks/src/use_coroutine.rs
  2. 1 1
      packages/hooks/src/use_future.rs
  3. 1 1
      packages/hooks/src/use_resource.rs

+ 4 - 4
packages/hooks/src/use_coroutine.rs

@@ -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

+ 1 - 1
packages/hooks/src/use_future.rs

@@ -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};
 

+ 1 - 1
packages/hooks/src/use_resource.rs

@@ -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};