Hello
When I try to run this example :
https://github.com/David-OConnor/seed/blob/master/examples/orders/src/lib.rs
I get the error :
wasm-bindgen: imported JS function that was not marked as
catchthrew an error: Illegal invocation
For gloo_timers::sys::clear_timeout
Thanks for your help
Hi, thanks for report!
Some questions:
wasm-pack -V) master branch?)rustc -V)target in Seed's root and pkg in example's folder?cargo make start orders from Seed's root to start that example?Do you see that error even after you delete folder target in Seed's root and pkg in example's folder?
Yes
Do you use cargo make start orders ?
No because cargo make dosen't want to install on my computer
I downgraded to your versions (on Windows) and I'm still not able to reproduce your problems.
cargo make dosen't want to install on my computer
I suggest to focus on cargo make error, because it's maybe somehow related to your issues, your development will be more comfortable and maybe you use different commands (than we use in cargo make start *) which cause problems.
So I downloaded the repo seed
And I did this in :
rustup update
rustup target add wasm32-unknown-unknown
cargo-make: cargo install --force cargo-make
cargo make start orders
And it works
I need to re-test in my project
Hello ,
I just saw that gloo 0.1.0 was realased 4 days ago :
https://crates.io/crates/gloo
馃帀馃帀馃帀
use gloo::{events::EventListener, timers::callback::Timeout};
Timeout::new(1_000, move || {
log!("test");
}).forget();
I will try to use I with my project to update model (with a future may-be)
Sweet. We've updated the code to use the crate, but haven't released the new version.
I was able to do this :
use gloo::{timers::callback::Timeout};
Timeout::new(1_000, move || {
let html_el = seed::document().get_element_by_id("toast").unwrap();
log!(html_el.class_name());
}).forget();
But if I try this :
Timeout::new(1_000, move || {
log!(model.msg);
}).forget();
I have this error :
explicit lifetime required in the type of
model
lifetime'staticrequired
any idea ?
@TuntematonSotilas: I think that 'static is required in your example because of https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/closure/struct.Closure.html (see description at the top).
So you have to make sure your model is 'static or close only msg (which has to be also 'static, of course).
Example:
let msg = model.msg.clone();
Timeout::new(1_000, move || {
log!(msg);
}).forget();
Or you can probably use macro enc! or enclose! - https://docs.rs/enclose/1.1.8/enclose/ for more readable code (you can search Seed's code for examples).
@TuntematonSotilas But on the second look - you probably want to know value of property msg from the _current_ model, after the given delay.
So try to get App instance from orders and send it into the closure. App is behind the Rc so it should be 'static and you should be able to get model from it or at least call update function, where you can use current model.
Example here: https://github.com/David-OConnor/seed/blob/master/examples/animation_frame/src/lib.rs#L72
Thanks it works perfectly with :
let (app, msg_mapper) = (orders.clone_app(), orders.msg_mapper());
Timeout::new(5_000, move || {
app.update(msg_mapper(Msg::Hide));
}).forget();