Skip to content

Commit

Permalink
Connect receiving end after creating window
Browse files Browse the repository at this point in the history
Co-authored-by: Alyssa Ross <[email protected]>
  • Loading branch information
swick and alyssais committed Dec 8, 2024
1 parent 7c3fde5 commit 4b31c41
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod imp {
root: ObjId,
backend_shutdown_tx: oneshot::Sender<()>,
tx: mpsc::Sender<Vec<u8>>,
rx: RefCell<Option<mpsc::Receiver<Vec<u8>>>>,
}

impl AardvarkApplication {
Expand Down Expand Up @@ -80,19 +81,14 @@ mod imp {
.unwrap();
let automerge = RefCell::new(am);

let (backend_shutdown_tx, tx, mut rx) = network::run().expect("running p2p backend");

glib::spawn_future_local(async move {
while let Some(msg) = rx.recv().await {
println!("got {:?}", msg);
}
});
let (backend_shutdown_tx, tx, rx) = network::run().expect("running p2p backend");

AardvarkApplication {
automerge,
root,
backend_shutdown_tx,
tx,
rx: RefCell::new(Some(rx)),
window: OnceCell::new(),
}
}
Expand Down Expand Up @@ -125,6 +121,14 @@ mod imp {
app.imp().update_text(text);
}),
);

let mut rx = application.imp().rx.take().unwrap();
glib::spawn_future_local(async move {
while let Some(msg) = rx.recv().await {
println!("got {:?}", msg);
}
});

window
}).clone();

Expand Down

0 comments on commit 4b31c41

Please sign in to comment.