Function dioxus_hooks::use_reactive

source ·
pub fn use_reactive<O, D: Dependency>(
    non_reactive_data: D,
    closure: impl FnMut(D::Out) -> O + 'static,
) -> impl FnMut() -> O + 'static
Expand description

Takes some non-reactive data, and a closure and returns a closure that will subscribe to that non-reactive data as if it were reactive.

§Example

use dioxus::prelude::*;

let data = 5;

use_effect(use_reactive((&data,), |(data,)| {
    println!("Data changed: {}", data);
}));