From e3e48148f02201e15ac22557945198ce9b35aa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Barreteau?= Date: Sat, 13 Feb 2021 10:43:42 +0100 Subject: [PATCH] Rename `add_event_emitter` to `set_event_emitter` Closes #145. --- matrix_sdk/examples/autojoin.rs | 2 +- matrix_sdk/examples/command_bot.rs | 2 +- matrix_sdk/examples/image_bot.rs | 2 +- matrix_sdk/examples/login.rs | 2 +- matrix_sdk/src/client.rs | 4 ++-- matrix_sdk_base/src/client.rs | 2 +- matrix_sdk_base/src/event_emitter/mod.rs | 10 +++++----- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/matrix_sdk/examples/autojoin.rs b/matrix_sdk/examples/autojoin.rs index c8f376ee..0e0a0509 100644 --- a/matrix_sdk/examples/autojoin.rs +++ b/matrix_sdk/examples/autojoin.rs @@ -78,7 +78,7 @@ async fn login_and_sync( println!("logged in as {}", username); client - .add_event_emitter(Box::new(AutoJoinBot::new(client.clone()))) + .set_event_emitter(Box::new(AutoJoinBot::new(client.clone()))) .await; client.sync(SyncSettings::default()).await; diff --git a/matrix_sdk/examples/command_bot.rs b/matrix_sdk/examples/command_bot.rs index 0afca9b9..d4dbfa43 100644 --- a/matrix_sdk/examples/command_bot.rs +++ b/matrix_sdk/examples/command_bot.rs @@ -88,7 +88,7 @@ async fn login_and_sync( // add our CommandBot to be notified of incoming messages, we do this after the initial // sync to avoid responding to messages before the bot was running. client - .add_event_emitter(Box::new(CommandBot::new(client.clone()))) + .set_event_emitter(Box::new(CommandBot::new(client.clone()))) .await; // since we called `sync_once` before we entered our sync loop we must pass diff --git a/matrix_sdk/examples/image_bot.rs b/matrix_sdk/examples/image_bot.rs index 344495df..bd81a033 100644 --- a/matrix_sdk/examples/image_bot.rs +++ b/matrix_sdk/examples/image_bot.rs @@ -86,7 +86,7 @@ async fn login_and_sync( client.sync_once(SyncSettings::default()).await.unwrap(); client - .add_event_emitter(Box::new(ImageBot::new(client.clone(), image))) + .set_event_emitter(Box::new(ImageBot::new(client.clone(), image))) .await; let settings = SyncSettings::default().token(client.sync_token().await.unwrap()); diff --git a/matrix_sdk/examples/login.rs b/matrix_sdk/examples/login.rs index 37440ac2..4b253df8 100644 --- a/matrix_sdk/examples/login.rs +++ b/matrix_sdk/examples/login.rs @@ -44,7 +44,7 @@ async fn login( let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); let client = Client::new(homeserver_url).unwrap(); - client.add_event_emitter(Box::new(EventCallback)).await; + client.set_event_emitter(Box::new(EventCallback)).await; client .login(username, password, None, Some("rust-sdk")) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index b52f4bea..463e8269 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -556,8 +556,8 @@ impl Client { /// Add `EventEmitter` to `Client`. /// /// The methods of `EventEmitter` are called when the respective `RoomEvents` occur. - pub async fn add_event_emitter(&self, emitter: Box) { - self.base_client.add_event_emitter(emitter).await; + pub async fn set_event_emitter(&self, emitter: Box) { + self.base_client.set_event_emitter(emitter).await; } /// Returns the joined rooms this client knows about. diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 0e0da616..0885bd6d 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -430,7 +430,7 @@ impl BaseClient { /// Add `EventEmitter` to `Client`. /// /// The methods of `EventEmitter` are called when the respective `RoomEvents` occur. - pub async fn add_event_emitter(&self, emitter: Box) { + pub async fn set_event_emitter(&self, emitter: Box) { let emitter = Emitter { inner: emitter, store: self.store.clone(), diff --git a/matrix_sdk_base/src/event_emitter/mod.rs b/matrix_sdk_base/src/event_emitter/mod.rs index db5f4e58..1bf7830d 100644 --- a/matrix_sdk_base/src/event_emitter/mod.rs +++ b/matrix_sdk_base/src/event_emitter/mod.rs @@ -746,7 +746,7 @@ mod test { let emitter = Box::new(EvEmitterTest(vec)); let client = get_client().await; - client.add_event_emitter(emitter).await; + client.set_event_emitter(emitter).await; let response = sync_response(SyncResponseFile::Default); client.receive_sync_response(response).await.unwrap(); @@ -778,7 +778,7 @@ mod test { let emitter = Box::new(EvEmitterTest(vec)); let client = get_client().await; - client.add_event_emitter(emitter).await; + client.set_event_emitter(emitter).await; let response = sync_response(SyncResponseFile::Invite); client.receive_sync_response(response).await.unwrap(); @@ -801,7 +801,7 @@ mod test { let emitter = Box::new(EvEmitterTest(vec)); let client = get_client().await; - client.add_event_emitter(emitter).await; + client.set_event_emitter(emitter).await; let response = sync_response(SyncResponseFile::Leave); client.receive_sync_response(response).await.unwrap(); @@ -831,7 +831,7 @@ mod test { let emitter = Box::new(EvEmitterTest(vec)); let client = get_client().await; - client.add_event_emitter(emitter).await; + client.set_event_emitter(emitter).await; let response = sync_response(SyncResponseFile::All); client.receive_sync_response(response).await.unwrap(); @@ -856,7 +856,7 @@ mod test { let emitter = Box::new(EvEmitterTest(vec)); let client = get_client().await; - client.add_event_emitter(emitter).await; + client.set_event_emitter(emitter).await; let response = sync_response(SyncResponseFile::Voip); client.receive_sync_response(response).await.unwrap();