Add argument to use_callback (#2774)

This commit is contained in:
Matt Hunzinger authored and GitHub committed 2024-08-02 16:15:59 -07:00
1 parent 14081e7e45
commit 205d8e9070
6 files changed
+34 -33

No files matched your search

+5 -5
View File
@@ -28,7 +28,7 @@ where
(rc, Rc::new(Cell::new(Some(changed))))
});
let cb = use_callback(move || {
let cb = use_callback(move |_| {
// Create the user's task
let fut = rc.reset_and_run_in(&mut future);
@@ -54,7 +54,7 @@ where
})
});
let mut task = use_hook(|| Signal::new(cb()));
let mut task = use_hook(|| Signal::new(cb(())));
use_hook(|| {
let mut changed = changed.take().unwrap();
@@ -67,7 +67,7 @@ where
task.write().cancel();
// Start a new task
task.set(cb());
task.set(cb(()));
}
})
});
@@ -110,7 +110,7 @@ pub struct Resource<T: 'static> {
value: Signal<Option<T>>,
task: Signal<Task>,
state: Signal<UseResourceState>,
callback: UseCallback<Task>,
callback: UseCallback<(), Task>,
}
impl<T> PartialEq for Resource<T> {
@@ -174,7 +174,7 @@ impl<T> Resource<T> {
/// ```
pub fn restart(&mut self) {
self.task.write().cancel();
let new_task = self.callback.call();
let new_task = self.callback.call(());
self.task.set(new_task);
}