Ver código fonte

clippy: remove unused module

Jonathan Kelley 3 anos atrás
pai
commit
74f40da997
2 arquivos alterados com 0 adições e 67 exclusões
  1. 0 3
      packages/hooks/src/lib.rs
  2. 0 64
      packages/hooks/src/usecallback.rs

+ 0 - 3
packages/hooks/src/lib.rs

@@ -13,9 +13,6 @@ pub use usecoroutine::*;
 mod usefuture;
 pub use usefuture::*;
 
-mod usecallback;
-pub use usecallback::*;
-
 mod useeffect;
 pub use useeffect::*;
 

+ 0 - 64
packages/hooks/src/usecallback.rs

@@ -1,64 +0,0 @@
-use std::{cell::RefCell, rc::Rc};
-
-use crate::use_state;
-use crate::UseFutureDep;
-use dioxus_core::{ScopeState, UiEvent};
-use std::future::Future;
-
-pub fn use_callback<I, G: UseFutureDep, F: Future<Output = ()> + 'static>(
-    cx: &ScopeState,
-    g: G,
-    f: impl FnMut(I, G::Out) -> F,
-) -> &UseCallback<I, G::Out>
-where
-    G::Out: 'static,
-    I: 'static,
-{
-    cx.use_hook(|_| {
-        //
-        UseCallback {
-            f: todo!(),
-            f2: Box::new(|f| {}),
-        }
-    })
-}
-
-pub struct UseCallback<I, T> {
-    f: Rc<RefCell<Option<Box<dyn FnMut(I, T)>>>>,
-    f2: Box<dyn Fn(I)>,
-}
-
-impl<I: 'static, T> std::ops::Deref for UseCallback<I, T> {
-    type Target = dyn Fn(I);
-
-    fn deref(&self) -> &Self::Target {
-        &self.f2
-    }
-}
-
-#[test]
-fn demo() {
-    use dioxus_core::prelude::*;
-    fn example(cx: Scope) -> Element {
-        let (name, _) = use_state(&cx, || 0);
-        let (age, _) = use_state(&cx, || 0);
-
-        let onsubmit = use_callback(&cx, (name,), |event: (), (name,)| async move {
-            //
-        });
-
-        let onsubmit = use_callback(&cx, (name,), my_callback);
-
-        async fn my_callback(event: UiEvent<()>, name: (i32,)) {
-            //
-        }
-
-        let onsubmit = use_callback(&cx, name, my_callback2);
-
-        async fn my_callback2(event: UiEvent<()>, name: i32) {
-            //
-        }
-
-        None
-    }
-}