1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Move http fetch api from eframe to epi

This commit is contained in:
Emil Ernerfeldt
2020-12-31 14:31:11 +01:00
parent 9db1b8dbf9
commit 375e317547
8 changed files with 240 additions and 129 deletions

View File

@@ -66,3 +66,20 @@ async fn fetch_jsvalue(request: &Request) -> Result<Response, JsValue> {
text,
})
}
// ----------------------------------------------------------------------------
pub(crate) struct WebHttp {}
impl epi::backend::Http for WebHttp {
fn fetch_dyn(
&self,
request: Request,
on_done: Box<dyn FnOnce(Result<Response, String>) + Send>,
) {
crate::spawn_future(async move {
let result = crate::http::fetch_async(&request).await;
on_done(result)
});
}
}