yew-tutorial
yew-tutorial copied to clipboard
Outdated code in tut 5
Hey dude! Great tutorial, thanks!
Just wanted to let you know that in stage 5, you have this code:
impl HostipService {
pub fn new() -> Self {
Self {
fetchserv: FetchService::new(),
}
}
But there's no option to do this, I assume since yew got quite a lot of updates since your tutorial. Now instead of creating the service all you need to do is use FetchService and call the fetch function.
use yew::services::fetch::{FetchService, ....};
FetchService::fetch(request, handler.into()).unwrap()
My env info:
❯ cargo version
cargo 1.45.1 (f242df6ed 2020-07-22)
❯ rustc --version
rustc 1.45.2 (d3fb005a3 2020-07-31)
and in Cargo.toml:
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
yew = "0.17"
Hi, thanks, also for pointing out this.
About the code: I'm using the new yew, version 0.17 in later tutorials.
For part 5 the actual version is 0.12, as shown in Cargo.toml:
[dependencies]
wasm-bindgen = "^0.2"
yew = "0.12"
web-sys = { version = "0.3", features = ["console"] }
In later tutorials I go about explaining new features of later Yew versions.
This is a clear example of how we need in the Rust ecosystem of stabilizing the interface of the libraries. In any case, Yew is still growing and while usable, it needs still improving and should be used in production carefully.