pub struct FetchTask(/* private fields */);Expand description
A handle to control sent requests. Can be canceled with a Task::cancel call.
Implementations§
Source§impl FetchTask
impl FetchTask
Sourcepub fn new(
request: Request<Value>,
yew_callback: Callback<Response<String>>,
) -> FetchTask
pub fn new( request: Request<Value>, yew_callback: Callback<Response<String>>, ) -> FetchTask
Sends a request to a remote server given a Request object and a callback fuction to convert a Response object into a loop’s message.
You may use a Request builder to build your request declaratively as on the following examples:
§Examples
use http::Request;
let post_request = Request::post("https://my.api/v1/resource")
.header("Content-Type", "application/json")
.body("Some data".to_string())
.expect("Failed to build request.");You then attach the callback to the context using context.send_back.
ⓘ
fn handle_response_initial(response: http::Response<String>) -> Msg {
// Your code here.
}
let callback = context.send_back(handle_response_initial);Trait Implementations§
Auto Trait Implementations§
impl Freeze for FetchTask
impl RefUnwindSafe for FetchTask
impl Send for FetchTask
impl Sync for FetchTask
impl Unpin for FetchTask
impl UnwindSafe for FetchTask
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more