1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40: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

@@ -42,3 +42,20 @@ pub fn fetch_blocking(request: &Request) -> Result<Response, String> {
};
Ok(response)
}
// ----------------------------------------------------------------------------
pub(crate) struct GliumHttp {}
impl epi::backend::Http for GliumHttp {
fn fetch_dyn(
&self,
request: Request,
on_done: Box<dyn FnOnce(Result<Response, String>) + Send>,
) {
std::thread::spawn(move || {
let result = crate::http::fetch_blocking(&request);
on_done(result)
});
}
}