docs(sdk): Add an example that attaches data to an event handler
This commit is contained in:
parent
804a941762
commit
913cb39d28
1 changed files with 13 additions and 0 deletions
|
@ -970,6 +970,19 @@ impl Client {
|
||||||
/// todo!("Display the token");
|
/// todo!("Display the token");
|
||||||
/// },
|
/// },
|
||||||
/// ).await;
|
/// ).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<MessageEventContent> | {
|
||||||
|
/// let data = data.clone();
|
||||||
|
/// async move {
|
||||||
|
/// println!("Calling the handler with identifier {}", data);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }).await;
|
||||||
/// # };
|
/// # };
|
||||||
/// ```
|
/// ```
|
||||||
pub async fn register_event_handler<Ev, Ctx, H>(&self, handler: H) -> &Self
|
pub async fn register_event_handler<Ev, Ctx, H>(&self, handler: H) -> &Self
|
||||||
|
|
Loading…
Reference in a new issue