diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 0cee924a..58ef9683 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -917,14 +917,17 @@ impl Client { /// }; /// use serde::{Deserialize, Serialize}; /// - /// client.register_event_handler( - /// |ev: SyncMessageEvent, room: Room, client: Client| async move { - /// // Common usage: Room event plus room and client. - /// }, - /// ).await; - /// client.register_event_handler(|ev: SyncStateEvent| async move { - /// // Also possible: Omit any or all arguments after the first. - /// }).await; + /// client + /// .register_event_handler( + /// |ev: SyncMessageEvent, room: Room, client: Client| async move { + /// // Common usage: Room event plus room and client. + /// }, + /// ) + /// .await + /// .register_event_handler(|ev: SyncStateEvent| async move { + /// // Also possible: Omit any or all arguments after the first. + /// }) + /// .await; /// /// // Custom events work exactly the same way, you just need to declare the content struct and /// // use the EventContent derive macro on it. @@ -942,7 +945,7 @@ impl Client { /// }, /// ).await; /// ``` - pub async fn register_event_handler(&self, handler: H) + pub async fn register_event_handler(&self, handler: H) -> &Self where Ev: SyncEvent + DeserializeOwned + Send + 'static, H: EventHandler, @@ -972,6 +975,8 @@ impl Client { } .boxed() })); + + self } /// Get all the rooms the client knows about.