mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 21:00:03 -04:00
Add http fetch to eframe and implement it in egui_glium using ureq
This commit is contained in:
@@ -10,10 +10,7 @@ crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../eframe" }
|
||||
egui_web = { path = "../egui_web" }
|
||||
image = { version = "0.23", default_features = false, features = ["jpeg", "png"] }
|
||||
js-sys = "0.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
syntect = { version = "4", default_features = false, features = ["default-fancy"] }
|
||||
wasm-bindgen = "0.2"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use eframe::{egui, epi};
|
||||
use egui_web::fetch::Response;
|
||||
use epi::http::Response;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
struct Resource {
|
||||
@@ -76,8 +76,9 @@ impl epi::App for ExampleApp {
|
||||
let repaint_signal = integration_context.repaint_signal.clone();
|
||||
let (sender, receiver) = std::sync::mpsc::channel();
|
||||
self.in_progress = Some(receiver);
|
||||
egui_web::spawn_future(async move {
|
||||
sender.send(egui_web::fetch::get(&url).await).ok();
|
||||
|
||||
eframe::http::fetch(eframe::http::Request::get(url), move |response| {
|
||||
sender.send(response).ok();
|
||||
repaint_signal.request_repaint();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#![warn(clippy::all)]
|
||||
|
||||
mod example_app;
|
||||
pub use example_app::ExampleApp;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use eframe::wasm_bindgen::{self, prelude::*};
|
||||
|
||||
9
example_web/src/main.rs
Normal file
9
example_web/src/main.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
#![forbid(unsafe_code)]
|
||||
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
|
||||
#![warn(clippy::all)]
|
||||
|
||||
// When compiling natively:
|
||||
fn main() {
|
||||
let app = example_web::ExampleApp::default();
|
||||
eframe::run_native(Box::new(app));
|
||||
}
|
||||
Reference in New Issue
Block a user