Struct yew_simple::FetchTask

source ·
pub struct FetchTask(_);
Expand description

A handle to control sent requests. Can be canceled with a Task::cancel call.

Implementations

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

Executes the destructor for this type. Read more
Returns true if task is active.
Cancel current service’s routine.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.