-
Hello Yew! I am trying to use Yew in an SPA alongside some external Javascript. I'm looking for the right way to enable the Javascript code to change the current route in my Yew application without causing a network reload. I believe I need a small bit of JS to deliver a message to my Yew app and have the app use the Navigation API. I took a look around the Yew discussions and found a few ongoing topics that seem somewhat related:
Something like Elm subscriptions may be what I'm looking for. If I were doing this in Elm I'd declare a port, have my Javascript send a message to it and use a subscription to trigger an update to Browser.Navigation. While looking for examples that send data from JS to Yew I did come across this post from craftyc0der which uses the So to summarize,
I have also posted this question (How to control Yew route from external JS in SPA?) to Stack Overflow and Reddit r/rust. I will follow up with a simple example/gist/playground/post/whatever once I work out the details for anyone else curious about how to do this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found a way to do what I need by having
See example here: https://github.com/jq170727/change_yew_route_from_js This works but I'm sure it could be improved. Suggestions or coding advice always appreciated 🙂 |
Beta Was this translation helpful? Give feedback.
I found a way to do what I need by having
See example here: https://github.com/jq170727/change_yew_route_from_js
This works but I'm sure it could be improved. Suggestions or coding advice always appreciated 🙂