Yew: Rename Switch trait

Created on 17 Dec 2019  路  1Comment  路  Source: yewstack/yew

Description

While Switch is an ok name for what it does, I think something along the lines of Routable would be more appropriate.

I don't intend to make this change for 8.0, but would like to create this issue so that interested parties can prepare their codebase for this change.


This change will come in 3 pieces.

  1. Add Routable alias (0.8.0)
  2. Rewrite macro & Trait to use Routable instead, deprecate Switch, make Switch an alias to Routable (0.9.0)
  3. Remove Switch (0.10.0)
breaking change proposal router

Most helpful comment

@hgzimmerman Also, I think it would make much more sense to name the to attribute at instead:

#[derive(Switch, Debug)]
pub enum AppRoute {
    #[at = "/profile/{id}"]
    Profile(u32),
    #[at = "/forum{*:rest}"]
    Forum(ForumRoute),
    #[at = "/"]
    Index,
}

#[derive(Switch, Debug)]
pub enum ForumRoute {
    #[at = "/{subforum}/{thread_slug}"]
    SubForumAndThread{subforum: String, thread_slug: String}
    #[at = "/{subforum}"]
    SubForum{subforum: String}
}

Because links/buttons route to somewhere (it's an action to follow a link) but the routes are defined at a certain url, and at also reflects the fact that it's declarative better.

>All comments

@hgzimmerman Also, I think it would make much more sense to name the to attribute at instead:

#[derive(Switch, Debug)]
pub enum AppRoute {
    #[at = "/profile/{id}"]
    Profile(u32),
    #[at = "/forum{*:rest}"]
    Forum(ForumRoute),
    #[at = "/"]
    Index,
}

#[derive(Switch, Debug)]
pub enum ForumRoute {
    #[at = "/{subforum}/{thread_slug}"]
    SubForumAndThread{subforum: String, thread_slug: String}
    #[at = "/{subforum}"]
    SubForum{subforum: String}
}

Because links/buttons route to somewhere (it's an action to follow a link) but the routes are defined at a certain url, and at also reflects the fact that it's declarative better.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djahandarie picture djahandarie  路  3Comments

jstarry picture jstarry  路  4Comments

sackery picture sackery  路  3Comments

alun picture alun  路  4Comments

DenisKolodin picture DenisKolodin  路  5Comments