wip: overhaul event system

This commit is contained in:
Jonathan Kelley committed 2022-11-15 16:05:22 -08:00
1 parent c44bd11fe5
commit 47d0f51e00
48 files changed
+3175 -2597

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
use std::{collections::HashMap, sync::Arc};
/* DOMEvent: Send + SyncTarget relatedTarget */
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone)]
pub struct FormEvent {
pub value: String,
pub values: HashMap<String, String>,
#[cfg_attr(feature = "serialize", serde(skip))]
pub files: Option<Arc<dyn FileEngine>>,
}
#[async_trait::async_trait(?Send)]
pub trait FileEngine {
// get a list of file names
fn files(&self) -> Vec<String>;
// read a file to bytes
async fn read_file(&self, file: &str) -> Option<Vec<u8>>;
// read a file to string
async fn read_file_to_string(&self, file: &str) -> Option<String>;
}
impl_event! {
FormEvent;
/// onchange
onchange
/// oninput handler
oninput
/// oninvalid
oninvalid
/// onreset
onreset
/// onsubmit
onsubmit
}