From 913cb39d28a73d464e3ab348a8b7bc891015ac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 9 Sep 2021 20:29:28 +0200 Subject: [PATCH] docs(sdk): Add an example that attaches data to an event handler --- matrix_sdk/src/client.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index e1634dda..4734ed51 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -970,6 +970,19 @@ impl Client { /// todo!("Display the token"); /// }, /// ).await; + /// + /// // Adding your custom data to the handler can be done as well + /// let data = "MyCustomIdentifier".to_string(); + /// + /// client.register_event_handler({ + /// let data = data.clone(); + /// move |ev: SyncMessageEvent | { + /// let data = data.clone(); + /// async move { + /// println!("Calling the handler with identifier {}", data); + /// } + /// } + /// }).await; /// # }; /// ``` pub async fn register_event_handler(&self, handler: H) -> &Self