diff options
| author | 2019-12-10 03:43:00 +0100 | |
|---|---|---|
| committer | 2019-12-10 03:43:00 +0100 | |
| commit | cdb7acf6c20fe13a09e75ea1c47d53ced6174698 (patch) | |
| tree | fb96d1a6fbc762a323c72d840e4902a2b0d45f4c /winit | |
| parent | e189c22bb09e471e8f899ef184d2a99e2e22c484 (diff) | |
| download | iced-cdb7acf6c20fe13a09e75ea1c47d53ced6174698.tar.gz iced-cdb7acf6c20fe13a09e75ea1c47d53ced6174698.tar.bz2 iced-cdb7acf6c20fe13a09e75ea1c47d53ced6174698.zip  | |
Implement `Subscription::map` and `from_recipe`
Diffstat (limited to '')
| -rw-r--r-- | winit/src/application.rs | 20 | 
1 files changed, 14 insertions, 6 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 49a01320..fb31c44f 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -2,8 +2,8 @@ use crate::{      conversion,      input::{keyboard, mouse},      renderer::{Target, Windowed}, -    Cache, Command, Container, Debug, Element, Event, Length, MouseCursor, -    Settings, Subscription, UserInterface, +    Cache, Command, Container, Debug, Element, Event, Hasher, Length, +    MouseCursor, Settings, Subscription, UserInterface,  };  use std::collections::HashMap; @@ -448,11 +448,19 @@ impl Subscriptions {      ) {          use futures::{future::FutureExt, stream::StreamExt}; -        let connections = subscriptions.connections(); +        let recipes = subscriptions.recipes();          let mut alive = std::collections::HashSet::new(); -        for connection in connections { -            let id = connection.id(); +        for recipe in recipes { +            let id = { +                use std::hash::Hasher as _; + +                let mut hasher = Hasher::default(); +                recipe.hash(&mut hasher); + +                hasher.finish() +            }; +              let _ = alive.insert(id);              if !self.alive.contains_key(&id) { @@ -460,7 +468,7 @@ impl Subscriptions {                  let (event_sender, event_receiver) =                      futures::channel::mpsc::channel(100); -                let stream = connection.stream(event_receiver); +                let stream = recipe.stream(event_receiver);                  let proxy =                      std::sync::Arc::new(std::sync::Mutex::new(proxy.clone()));  | 
