Remove push_future, get use_future kinda working again

This commit is contained in:
Jonathan Kelley committed 2024-01-15 19:34:04 -08:00
1 parent 14651a3573
commit a32ae8b112
8 files changed
+49 -60

No files matched your search

-21
View File
@@ -42,27 +42,6 @@ pub fn use_effect(callback: impl FnMut() + 'static) {
use_hook(|| Effect::new(callback));
}
/// Create a new effect. The effect will be run immediately and whenever any signal it reads changes.
/// The signal will be owned by the current component and will be dropped when the component is dropped.
pub fn use_effect_with_dependencies<D: Dependency>(
dependencies: D,
mut callback: impl FnMut(D::Out) + 'static,
) where
D::Out: 'static,
{
let dependencies_signal = use_signal(|| dependencies.out());
use_hook(|| {
Effect::new(move || {
let deref = &*dependencies_signal.read();
callback(deref.clone());
});
});
let changed = { dependencies.changed(&*dependencies_signal.read()) };
if changed {
dependencies_signal.set(dependencies.out());
}
}
/// Effects allow you to run code when a signal changes. Effects are run immediately and whenever any signal it reads changes.
#[derive(Copy, Clone, PartialEq)]
pub struct Effect {