diff --git a/examples/dashboard/client/src/main.rs b/examples/dashboard/client/src/main.rs index bab7de08b..6a1d204c0 100644 --- a/examples/dashboard/client/src/main.rs +++ b/examples/dashboard/client/src/main.rs @@ -6,8 +6,8 @@ extern crate yew; use yew::prelude::*; use yew::format::{Nothing, Json}; use yew::services::Task; -use yew::services::fetch::{FetchService, Request, Response}; -use yew::services::websocket::{WebSocketService, WebSocketHandle, WebSocketStatus}; +use yew::services::fetch::{FetchService, FetchTask, Request, Response}; +use yew::services::websocket::{WebSocketService, WebSocketTask, WebSocketStatus}; struct Context { web: FetchService, @@ -17,7 +17,8 @@ struct Context { struct Model { fetching: bool, data: Option, - ws: Option, + ft: Option, + ws: Option, } enum WsAction { @@ -68,6 +69,7 @@ impl Component for Model { Model { fetching: false, data: None, + ft: None, ws: None, } } @@ -85,7 +87,8 @@ impl Component for Model { } }); let request = Request::get("/data.json").body(Nothing).unwrap(); - context.web.fetch(request, callback); + let task = context.web.fetch(request, callback); + self.ft = Some(task); } Msg::WsAction(action) => { match action { @@ -97,8 +100,8 @@ impl Component for Model { WebSocketStatus::Closed => WsAction::Lost.into(), } }); - let handle = context.ws.connect("ws://localhost:9001/", callback, notification); - self.ws = Some(handle); + let task = context.ws.connect("ws://localhost:9001/", callback, notification); + self.ws = Some(task); } WsAction::SendData => { let request = WsRequest { diff --git a/examples/npm_and_rest/src/gravatar.rs b/examples/npm_and_rest/src/gravatar.rs index 89bed62ef..c58e54519 100644 --- a/examples/npm_and_rest/src/gravatar.rs +++ b/examples/npm_and_rest/src/gravatar.rs @@ -1,5 +1,5 @@ use yew::format::{Nothing, Json}; -use yew::services::fetch::{FetchService, FetchHandle, Request, Response}; +use yew::services::fetch::{FetchService, FetchTask, Request, Response}; use yew::html::Callback; #[derive(Deserialize, Debug)] @@ -28,7 +28,7 @@ impl GravatarService { } } - pub fn profile(&mut self, hash: &str, callback: Callback>) -> FetchHandle { + pub fn profile(&mut self, hash: &str, callback: Callback>) -> FetchTask { let url = format!("https://gravatar.com/{}", hash); let handler = move |response: Response>>| { let (_, Json(data)) = response.into_parts(); diff --git a/examples/npm_and_rest/src/main.rs b/examples/npm_and_rest/src/main.rs index 5b96a73ba..0fa0b36b5 100644 --- a/examples/npm_and_rest/src/main.rs +++ b/examples/npm_and_rest/src/main.rs @@ -6,6 +6,7 @@ extern crate stdweb; extern crate yew; use yew::prelude::*; +use yew::services::fetch::FetchTask; // Own services implementation mod gravatar; @@ -21,6 +22,7 @@ struct Context { struct Model { profile: Option, exchanges: Vec, + task: Option, } enum Msg { @@ -37,6 +39,7 @@ impl Component for Model { Model { profile: None, exchanges: Vec::new(), + task: None, } } @@ -44,7 +47,8 @@ impl Component for Model { match msg { Msg::Gravatar => { let callback = context.send_back(Msg::GravatarReady); - context.gravatar.profile("205e460b479e2e5b48aec07710c08d50", callback); + let task = context.gravatar.profile("205e460b479e2e5b48aec07710c08d50", callback); + self.task = Some(task); } Msg::GravatarReady(Ok(profile)) => { self.profile = Some(profile);