Commit c043f7c
Remove old macro
Changed files (2)
Diff
@@ -57,6 +57,5 @@ pub fn init() { let mut app_data = APP_DATA.read().unwrap(); update_counter_display(&app_data);- init_callbacks(); }@@ -159,53 +159,3 @@ pub fn try_inner_html(selector: &str, html: &str) { pub fn try_inner_text(selector: &str, text: &str) { let _ = inner_text(selector, text); }--#[macro_export]-macro_rules! callback {- ($js_name:ident, $rust_fn:path) => {{- use wasm_bindgen::closure::Closure;- use wasm_bindgen::JsCast;- use wasm_bindgen::JsValue;-- let window = web_sys::window().unwrap();-- let cb = Closure::<dyn FnMut(JsValue)>::new(|val: JsValue| {- let event: _ =- serde_wasm_bindgen::from_value(val).expect("Failed to deserialize event");-- $rust_fn(event);- });-- ::js_sys::Reflect::set(- &window,- &stringify!($js_name).into(),- cb.as_ref().unchecked_ref(),- )- .unwrap();-- cb.forget();- }};-}--#[cfg(all(test, target_arch = "wasm32"))]-mod tests {- use crate::App;- use crate::CallbackRegistration;- use gloo_console::log;- use js_sys;- #[derive(Debug, serde::Deserialize)]- struct SomeClickEvent {- índex: usize,- }-- #[kaja_callback_macro::callback("someClickCallback")]- fn some_on_click_function(event: SomeClickEvent) {- log!("event.índex: {:?}", event.índex);- }-- #[test]- fn test_compile() {- let app = App::new();- app.set_callbacks(); // 👈 registers ALL #[callback] functions automatically- }-}