From 897826f71056d385da9722b5bf4009e6600cfcb9 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 25 Aug 2021 17:35:27 +0200 Subject: [PATCH] Run subscription/observation callbacks in the order they were added Co-Authored-By: Nathan Sobo --- gpui/src/app.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gpui/src/app.rs b/gpui/src/app.rs index 8c8fd24485..5d1fdc3a49 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -18,7 +18,7 @@ use smol::prelude::*; use std::{ any::{type_name, Any, TypeId}, cell::RefCell, - collections::{hash_map::Entry, HashMap, HashSet, VecDeque}, + collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque}, fmt::{self, Debug}, hash::{Hash, Hasher}, marker::PhantomData, @@ -652,8 +652,8 @@ pub struct MutableAppContext { next_entity_id: usize, next_window_id: usize, next_subscription_id: usize, - subscriptions: Arc>>>, - observations: Arc>>>, + subscriptions: Arc>>>, + observations: Arc>>>, presenters_and_platform_windows: HashMap>, Box)>, debug_elements_callbacks: HashMap crate::json::Value>>, @@ -2967,12 +2967,12 @@ pub enum Subscription { Subscription { id: usize, entity_id: usize, - subscriptions: Option>>>>, + subscriptions: Option>>>>, }, Observation { id: usize, entity_id: usize, - observations: Option>>>>, + observations: Option>>>>, }, } @@ -3200,7 +3200,7 @@ mod tests { assert_eq!(handle_1.read(cx).events, vec![7]); handle_2.update(cx, |_, c| c.emit(5)); - assert_eq!(handle_1.read(cx).events, vec![7, 10, 5]); + assert_eq!(handle_1.read(cx).events, vec![7, 5, 10]); } #[crate::test(self)] @@ -3240,7 +3240,7 @@ mod tests { model.count = 5; c.notify() }); - assert_eq!(handle_1.read(cx).events, vec![7, 10, 5]) + assert_eq!(handle_1.read(cx).events, vec![7, 5, 10]) } #[crate::test(self)] @@ -3462,10 +3462,10 @@ mod tests { assert_eq!(handle_1.read(cx).events, vec![7]); handle_2.update(cx, |_, c| c.emit(5)); - assert_eq!(handle_1.read(cx).events, vec![7, 10, 5]); + assert_eq!(handle_1.read(cx).events, vec![7, 5, 10]); handle_3.update(cx, |_, c| c.emit(9)); - assert_eq!(handle_1.read(cx).events, vec![7, 10, 5, 9]); + assert_eq!(handle_1.read(cx).events, vec![7, 5, 10, 9]); } #[crate::test(self)]