Merge branch 'master' into intigrate-collect-assets
This commit is contained in:
commit
66e2c02bf7
168 files changed
+3727
-858
No files matched your search
@@ -294,7 +294,7 @@ pub fn virtual_event_from_websys_event(event: web_sys::Event, target: Element) -
|
||||
"select" => Rc::new(SelectionData {}),
|
||||
"touchcancel" | "touchend" | "touchmove" | "touchstart" => Rc::new(TouchData::from(event)),
|
||||
|
||||
"scroll" => Rc::new(()),
|
||||
"scroll" => Rc::new(ScrollData {}),
|
||||
"wheel" => Rc::new(WheelData::from(event)),
|
||||
"animationstart" | "animationend" | "animationiteration" => {
|
||||
Rc::new(AnimationData::from(event))
|
||||
|
||||
@@ -5,7 +5,6 @@ use futures_channel::mpsc::UnboundedReceiver;
|
||||
use dioxus_core::Template;
|
||||
|
||||
pub(crate) fn init() -> UnboundedReceiver<Template<'static>> {
|
||||
use std::convert::TryInto;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::{MessageEvent, WebSocket};
|
||||
@@ -31,14 +30,12 @@ pub(crate) fn init() -> UnboundedReceiver<Template<'static>> {
|
||||
// change the rsx when new data is received
|
||||
let cl = Closure::wrap(Box::new(move |e: MessageEvent| {
|
||||
if let Ok(text) = e.data().dyn_into::<js_sys::JsString>() {
|
||||
let text: Result<String, _> = text.try_into();
|
||||
if let Ok(string) = text {
|
||||
let val = serde_json::from_str::<serde_json::Value>(&string).unwrap();
|
||||
// leak the value
|
||||
let val: &'static serde_json::Value = Box::leak(Box::new(val));
|
||||
let template: Template<'_> = Template::deserialize(val).unwrap();
|
||||
tx.unbounded_send(template).unwrap();
|
||||
}
|
||||
let string: String = text.into();
|
||||
let val = serde_json::from_str::<serde_json::Value>(&string).unwrap();
|
||||
// leak the value
|
||||
let val: &'static serde_json::Value = Box::leak(Box::new(val));
|
||||
let template: Template<'_> = Template::deserialize(val).unwrap();
|
||||
tx.unbounded_send(template).unwrap();
|
||||
}
|
||||
}) as Box<dyn FnMut(MessageEvent)>);
|
||||
|
||||
|
||||
Reference in new issue
Block a user