Skip to content

Commit

Permalink
Return EventLoopClosed instead of panicking
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Sep 3, 2023
1 parent deab352 commit 67aed46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/platform_impl/web/event_loop/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::mpsc::Sender;
use std::sync::mpsc::{SendError, Sender};

use super::runner;
use crate::event_loop::EventLoopClosed;
Expand All @@ -15,7 +15,9 @@ impl<T: 'static> EventLoopProxy<T> {
}

pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed<T>> {
self.sender.send(event).unwrap();
self.sender
.send(event)
.map_err(|SendError(event)| EventLoopClosed(event))?;
self.runner.wake();
Ok(())
}
Expand Down

0 comments on commit 67aed46

Please sign in to comment.