Function freya_hooks::use_canvas_with_deps

source ·
pub fn use_canvas_with_deps<D: Dependency>(
    dependencies: D,
    renderer_cb: impl Fn(D::Out) -> Box<CanvasRunner> + 'static
) -> UseCanvas
where D::Out: 'static,
Expand description

Register a rendering hook to gain access to the Canvas. Reactivity managed with manual dependencies.

§Usage

fn app() -> Element {
    let value = use_signal(|| 0);

    let canvas = use_canvas_with_deps(&value(), |curr| {
        Box::new(move |canvas, font_collection, area, scale_factor| {
            // Draw using the canvas !
            // use `curr`
        })
    });

    rsx!(Canvas { canvas })
}