#dioxus #hook #optional #future #v04 #future-hook #startup-guard

dioxus-v04-optional-hooks

Optional futures for Dioxus 0.4.0-0.4.3

8 releases

0.3.0 Nov 4, 2024
0.2.4 Jul 8, 2024
0.2.0 Jun 24, 2024
0.1.1 May 28, 2024

#709 in Asynchronous

Download history 21/week @ 2024-07-24 10/week @ 2024-07-31 22/week @ 2024-09-11 15/week @ 2024-09-18 15/week @ 2024-09-25 105/week @ 2024-10-30 43/week @ 2024-11-06

148 downloads per month

MIT license

7KB
121 lines

dioxus-v04-optional-hooks

Simplifies future hooks that should be reusable.

Usage

use dioxus_v04_optional_hooks::{FutureHook, StartupGuard};
use dioxus::prelude::*;

...

let project_selected = use_state(cx, || 0);
let get_project_card_fut = FutureHook::new(cx, StartupGuard::Enable, (project_selected,), |(project_selected,)| async move {
    get_project_info(*project_selected).await
});

...

cx.render({
    get_project_card_fut.lazy_fetch();
    if let Some(project_card) = get_project_card_fut.read_clone(false) {
        ...
    }
})

Dependencies

~2MB
~31K SLoC