Skip to content

Commit

Permalink
Create an init() function to force initial route according to the URL
Browse files Browse the repository at this point in the history
(necessary since seed 0.4.0 - PR #189 'scalable application support'')
seed-rs/seed#189 (comment)
  • Loading branch information
levalleux-ludo committed Aug 2, 2019
1 parent 04e593b commit 879f9ad
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib.rs
Expand Up @@ -634,10 +634,19 @@ fn routes(url: seed::Url) -> Msg {
_ => Msg::Load(ActionLoad::Summary),
}
}
// ------ ------
// Init : to force the initial route according to the URL (necessary since seed 0.4.0 - PR #189 'scalable application support'')
// https://github.com/David-OConnor/seed/pull/189#issuecomment-517747635
// ------ ------

fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
orders.send_msg(routes(url));
Model::default()
}

#[wasm_bindgen]
pub fn render() {
let state = seed::App::build(|_, _| Model::default(), update, view)
let state = seed::App::build(init, update, view)
.routes(routes)
.finish()
.run();
Expand Down

0 comments on commit 879f9ad

Please sign in to comment.