dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Default values for route segments

Open AdrienPensart opened this issue 1 year ago • 1 comments

Feature Request

I would like to write something like this : #[route("/?:muted=true&:start=10")] there is many url-serde serializer/deserializer for this kind of usecase.

For now, I have to write this :

#[derive(Clone, Routable, Debug, PartialEq)]
enum Route {
    #[route("/?:muted&:start")]
    BoxingTimer {
        muted: bool,
        start: u64,
    },
}

#[component]
fn BoxingTimer(
    muted: bool,
    start: bool,
) -> Element {
    if start == 0 {
       start = 10
    }
    if muted {
        mute()
    }
}

thank you for this amazing project!

AdrienPensart avatar Aug 03 '24 13:08 AdrienPensart

We should allow Option<T> in query and hash segments which tries to parse the inner type and then falls back to None if it fails

ealmloff avatar Aug 05 '24 16:08 ealmloff