arn-the-long-beard / seed-routing

Prototype for having easy routing to use in Seed
MIT License
6 stars 2 forks source link

Use of implemented init trait on changed Url #20

Closed arn-the-long-beard closed 3 years ago

arn-the-long-beard commented 3 years ago

Right now, in order to init our pages we do it this way

 fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
     match msg {
         Msg::UrlChanged(subs::UrlChanged(_)) => {
             router().current_route().init(model, orders);
         }
         // ...remaining arms
     }
 }

In the same way we did moved |subs::UrlRequested(requested_url, _)| router().confirm_navigation(requested_url), to the main fn init of the lib.rs.

Lets try it and see if it simplifies the code and respect or improve the semantic of it :smile:

arn-the-long-beard commented 3 years ago

Well. In fact I cannot do this because we need to have an updated Model always. The init of pages has to be made in update anyway.