-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use request_animation_frame from rust instead of Global Js call for update view #144
Comments
Heads up I plan to address this issue over the weekend! Hang tight, sorry! |
What is In terms of requestAnimationFrame, I can update the example to show how to do it. I'd like to rewrite the example using some of the things that I've learned in the last couple of years, so this can be part of that work stream. |
Hi, nice to see a response :) So, Subscription is part of redux_rs crate, i think it works like your store in the example here : https://github.com/chinedufn/percy/blob/master/examples/isomorphic/app/src/store.rs and https://github.com/chinedufn/percy/blob/master/examples/isomorphic/client/src/lib.rs In your example you do this :
The definition of Subscription : https://docs.rs/redux-rs/0.1.0/redux_rs/type.Subscription.html I will wait for your example rewrite in this case ! Thanks ! |
I'm playing with Percy, and it's pretty cool, really a good feeling. But i'm not satisfied by the way I update my views.
In the isomorphic example you use a call to a function in JS from the rust listener to call a render code in the same crate, and you suggest to replace all of that by the use of request_animation_frame from rust : https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Window.html#method.request_animation_frame .
But i can't figure how to do that, can you help me ?
By the way i use the method of global js call, it's working but i'm curious :)
I can't find a way to update my view when my data is modified. Redux provide listeners, so i can do that :
But to upgrade my view I need a ref to the updater in the closure, so, i have add a move before my closure like this this :
After that, subscribers complain that it is not a function but a closure :
I did a research, a closure can be converted to an anonymous function but not if it captures its environment.
So when I use move, it's not convertible to function and it doesn't work anymore
Do you know how i can update my view with this callback ? I'm very new to Rust.
I put my code in example of the pb :
It's working but use code from Js to call render in Rust, I would love to do thing like that :
The text was updated successfully, but these errors were encountered: