Added explanation of the fetch module.#57
Added explanation of the fetch module.#57teymour-aldridge wants to merge 16 commits intoyewstack:masterfrom
Conversation
src/concepts/services/fetch.md
Outdated
| if meta.status.is_success() { | ||
| match data.message { | ||
| "success" => { | ||
| Self::Message::ReceiveLocation(data.clone()) |
There was a problem hiding this comment.
Not sure, I think not.
src/concepts/services/fetch.md
Outdated
| if meta.status.is_success() { | ||
| match data.message { | ||
| "success" => { |
There was a problem hiding this comment.
I think we should be more succinct here: if meta.status.is_success() && data.message == "success"
There was a problem hiding this comment.
Done (I think)!
src/concepts/services/fetch.md
Outdated
| fn view(&self) -> Html { | ||
| html! { | ||
| <> | ||
| {if self.fetching { |
There was a problem hiding this comment.
Can you please break out this block and the match self.iss block into their own methods on FetchServiceExample? I'd like the examples to set a good precedent for splitting up view logic
There was a problem hiding this comment.
Done (I think)!
Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
| // split up the response into the HTTP data about the request result and data from the request | ||
| let (meta, Json(data)) = response.into_parts(); | ||
| if meta.status.is_success() && data.message == "success" { | ||
| Self::Message::ReceiveLocation(match data { |
There was a problem hiding this comment.
Fixed this (I think).
src/concepts/services/fetch.md
Outdated
| ReceiveLocation(location) => { | ||
| self.iss = location; | ||
| self.fetching = false; | ||
| // we want to redraw so that the page no longer says 'fetching...' |
There was a problem hiding this comment.
nit: and also display the location!
| link: ComponentLink<Self> | ||
| } | ||
|
|
||
| impl FetchServiceExample { |
There was a problem hiding this comment.
nit: can you move this impl block under the impl Component block? It flows better because from top to bottom you see the methods right after seeing
fn view(&self) -> Html {
html! {
<>
{self.is_fetching()}
{self.view_iss_location()}
</>
}
}| // handle errors more properly than this | ||
| Err(_) => panic!("Could not handle this error") |
There was a problem hiding this comment.
Maybe we should handle the error to show a more complete example? Not sure if people get tripped up on error handling or not
There was a problem hiding this comment.
I'll add some error handling.
No description provided.