Where to call JS function

Where is the right place to call JS functions? In Elm, they’re called as Cmds in the update function. So if Seed is similar in that respect, I’d do something like this:

match msg {
    Msg::Login => { orders.perform_cmd(my_js_login_func(email, pass)) },
    // ...
}

Since my_js_login_func() needs to return a Future<Item = Ms, Error = Ms> + 'static, I would wrap it in some Rust function that does this.

Alternatively, I’m currently simply calling the JS function directly. Is there a problem doing this?

match msg {
    Msg::Login => my_js_login_func(email, pass),
    // ...
}

Elm’s ports and de/encoders were some of the reasons why I moved to Rust/Seed. Choose the simplest and the most suitable way for your use-case.

1 Like

Sorry for notified but i could not find any resource.

I have a js function in a js file. I imported it in my view. Now i have to call that function with seed. How can i do that?

@eribol
See https://rustwasm.github.io/docs/wasm-bindgen/introduction.html
and https://github.com/seed-rs/seed/blob/a0e01ae6d94f20870a6a07db4e258865e362a74a/examples/update_from_js/src/lib.rs#L108-L115

Please create a new topic / write on the chat if it’s not enough to resolve the problem. And sorry for the late response.