Introduce subscription::Event

... and remove `PlatformSpecific` from `Event`
This commit is contained in:
Héctor Ramón Jiménez 2024-06-11 19:41:05 +02:00
parent 83296a73eb
commit 5d7dcf417c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 156 additions and 129 deletions

View file

@ -1,6 +1,4 @@
use crate::core::event::{self, Event};
use crate::core::window;
use crate::subscription::{Hasher, Recipe};
use crate::subscription::{Event, Hasher, Recipe};
use crate::{BoxFuture, MaybeSend};
use futures::channel::mpsc;
@ -24,9 +22,7 @@ pub struct Tracker {
#[derive(Debug)]
pub struct Execution {
_cancel: futures::channel::oneshot::Sender<()>,
listener: Option<
futures::channel::mpsc::Sender<(Event, event::Status, window::Id)>,
>,
listener: Option<futures::channel::mpsc::Sender<Event>>,
}
impl Tracker {
@ -142,19 +138,12 @@ impl Tracker {
/// currently open.
///
/// [`Recipe::stream`]: crate::subscription::Recipe::stream
pub fn broadcast(
&mut self,
event: Event,
status: event::Status,
window: window::Id,
) {
pub fn broadcast(&mut self, event: Event) {
self.subscriptions
.values_mut()
.filter_map(|connection| connection.listener.as_mut())
.for_each(|listener| {
if let Err(error) =
listener.try_send((event.clone(), status, window))
{
if let Err(error) = listener.try_send(event.clone()) {
log::warn!(
"Error sending event to subscription: {error:?}"
);