Introduce window::Id to Event subscriptions

And remove `window::Id` from `Event` altogether.
This commit is contained in:
Héctor Ramón Jiménez 2024-06-04 23:20:33 +02:00
parent 49affc44ff
commit e400f972c1
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F
19 changed files with 95 additions and 91 deletions

View file

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