diff --git a/reactive_graph/src/computed.rs b/reactive_graph/src/computed.rs index 627d84914..56cf0ee8e 100644 --- a/reactive_graph/src/computed.rs +++ b/reactive_graph/src/computed.rs @@ -141,3 +141,48 @@ where { Memo::new(fun) } + +/// Creates a new memo by passing a function that computes the value. +#[inline(always)] +#[track_caller] +#[deprecated = "This function is being removed to conform to Rust idioms. \ + Please use `Memo::new_owning()` instead."] +pub fn create_owning_memo( + fun: impl Fn(Option) -> (T, bool) + Send + Sync + 'static, +) -> Memo +where + T: PartialEq + Send + Sync + 'static, +{ + Memo::new_owning(fun) +} + +/// A conditional signal that only notifies subscribers when a change +/// in the source signal’s value changes whether the given function is true. +#[inline(always)] +#[track_caller] +#[deprecated = "This function is being removed to conform to Rust idioms. \ + Please use `Selector::new()` instead."] +pub fn create_selector( + source: impl Fn() -> T + Clone + 'static, +) -> Selector +where + T: PartialEq + Eq + Clone + std::hash::Hash + 'static, +{ + Selector::new(source) +} + +/// Creates a conditional signal that only notifies subscribers when a change +/// in the source signal’s value changes whether the given function is true. +#[inline(always)] +#[track_caller] +#[deprecated = "This function is being removed to conform to Rust idioms. \ + Please use `Selector::new_with_fn()` instead."] +pub fn create_selector_with_fn( + source: impl Fn() -> T + Clone + 'static, + f: impl Fn(&T, &T) -> bool + Send + Sync + Clone + 'static, +) -> Selector +where + T: PartialEq + Eq + Clone + std::hash::Hash + 'static, +{ + Selector::new_with_fn(source, f) +} diff --git a/reactive_graph/src/effect.rs b/reactive_graph/src/effect.rs index f6aeaa680..bef29d70e 100644 --- a/reactive_graph/src/effect.rs +++ b/reactive_graph/src/effect.rs @@ -9,3 +9,17 @@ mod render_effect; pub use effect::*; pub use effect_function::*; pub use render_effect::*; + +/// Creates a new render effect, which immediately runs `fun`. +#[inline(always)] +#[track_caller] +#[deprecated = "This function is being removed to conform to Rust idioms. \ + Please use `RenderEffect::new()` instead."] +pub fn create_render_effect( + fun: impl FnMut(Option) -> T + 'static, +) -> RenderEffect +where + T: 'static, +{ + RenderEffect::new(fun) +} diff --git a/reactive_graph/src/signal.rs b/reactive_graph/src/signal.rs index 83c552c38..affebee9b 100644 --- a/reactive_graph/src/signal.rs +++ b/reactive_graph/src/signal.rs @@ -184,3 +184,12 @@ pub fn create_signal( pub fn create_rw_signal(value: T) -> RwSignal { RwSignal::new(value) } + +/// A trigger is a data-less signal with the sole purpose of notifying other reactive code of a change. +#[inline(always)] +#[track_caller] +#[deprecated = "This function is being removed to conform to Rust idioms. \ + Please use `ArcTrigger::new()` instead."] +pub fn create_trigger() -> ArcTrigger { + ArcTrigger::new() +}