fix: desktop and mobile

This commit is contained in:
Jonathan Kelley committed 2021-10-22 01:16:39 -04:00
1 parent f66cda4bed
commit 601078f9cf
23 files changed
+670 -132

No files matched your search

+17 -5
View File
@@ -95,13 +95,13 @@ pub fn run<T: 'static + Send + Sync>(
match event {
Event::NewEvents(StartCause::Init) => {
let window = WindowBuilder::new().build(&event_loop).unwrap();
let window = WindowBuilder::new().build(event_loop).unwrap();
let window_id = window.id();
let (event_tx, event_rx) = tokio::sync::mpsc::unbounded_channel();
let my_props = props_shared.take().unwrap();
let sender = launch_vdom_with_tokio(root, my_props, event_tx.clone());
let sender = launch_vdom_with_tokio(root, my_props, event_tx);
let locked_receiver = Rc::new(RefCell::new(event_rx));
@@ -121,10 +121,15 @@ pub fn run<T: 'static + Send + Sync>(
}
"user_event" => {
let event = events::trigger_from_serialized(req.params.unwrap());
log::debug!("User event: {:?}", event);
sender.unbounded_send(SchedulerMsg::UiEvent(event)).unwrap();
if let Some(BridgeEvent::Update(edits)) = rx.blocking_recv() {
log::info!("bridge received message {:?}", edits);
Some(RpcResponse::new_result(req.id.take(), Some(edits)))
} else {
log::info!("none received message");
None
}
}
@@ -224,13 +229,20 @@ pub(crate) fn launch_vdom_with_tokio<P: Send + 'static>(
let mut muts = vir.run_with_deadline(|| false);
log::debug!("finished running with deadline");
let mut edits = vec![];
while let Some(edit) = muts.pop() {
log::debug!("sending message on channel with edit {:?}", edit);
let edit_string = serde_json::to_value(Evt { edits: edit.edits })
.expect("serializing edits should never fail");
event_tx
.send(BridgeEvent::Update(edit_string))
.expect("Sending should not fail");
edits.push(edit_string);
}
event_tx
.send(BridgeEvent::Update(serde_json::Value::Array(edits)))
.expect("Sending should not fail");
}
})
});