client: Fix the sync_with_callback example
parent
19b78be93f
commit
e3d1de8e6c
|
@ -72,7 +72,6 @@ version = "3.0.2"
|
||||||
features = ["wasm-bindgen"]
|
features = ["wasm-bindgen"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
async-std = { version = "1.9.0", features = ["unstable"] }
|
|
||||||
dirs = "3.0.1"
|
dirs = "3.0.1"
|
||||||
matrix-sdk-test = { version = "0.2.0", path = "../matrix_sdk_test" }
|
matrix-sdk-test = { version = "0.2.0", path = "../matrix_sdk_test" }
|
||||||
tokio = { version = "1.1.0", default-features = false, features = ["rt-multi-thread", "macros"] }
|
tokio = { version = "1.1.0", default-features = false, features = ["rt-multi-thread", "macros"] }
|
||||||
|
|
|
@ -1702,11 +1702,10 @@ impl Client {
|
||||||
/// the interesting events through a mpsc channel to another thread e.g. a
|
/// the interesting events through a mpsc channel to another thread e.g. a
|
||||||
/// UI thread.
|
/// UI thread.
|
||||||
///
|
///
|
||||||
/// ```compile_fail,E0658
|
/// ```no_run
|
||||||
/// # use matrix_sdk::events::{
|
/// # use matrix_sdk::events::{
|
||||||
/// # room::message::{MessageEvent, MessageEventContent, TextMessageEventContent},
|
/// # room::message::{MessageEvent, MessageEventContent, TextMessageEventContent},
|
||||||
/// # };
|
/// # };
|
||||||
/// # use matrix_sdk::Room;
|
|
||||||
/// # use std::sync::{Arc, RwLock};
|
/// # use std::sync::{Arc, RwLock};
|
||||||
/// # use std::time::Duration;
|
/// # use std::time::Duration;
|
||||||
/// # use matrix_sdk::{Client, SyncSettings, LoopCtrl};
|
/// # use matrix_sdk::{Client, SyncSettings, LoopCtrl};
|
||||||
|
@ -1716,7 +1715,7 @@ impl Client {
|
||||||
/// # let homeserver = Url::parse("http://localhost:8080").unwrap();
|
/// # let homeserver = Url::parse("http://localhost:8080").unwrap();
|
||||||
/// # let mut client = Client::new(homeserver).unwrap();
|
/// # let mut client = Client::new(homeserver).unwrap();
|
||||||
///
|
///
|
||||||
/// use async_std::sync::channel;
|
/// use tokio::sync::mpsc::channel;
|
||||||
///
|
///
|
||||||
/// let (tx, rx) = channel(100);
|
/// let (tx, rx) = channel(100);
|
||||||
///
|
///
|
||||||
|
@ -1725,14 +1724,12 @@ impl Client {
|
||||||
/// .timeout(Duration::from_secs(30));
|
/// .timeout(Duration::from_secs(30));
|
||||||
///
|
///
|
||||||
/// client
|
/// client
|
||||||
/// .sync_with_callback(sync_settings, async move |response| {
|
/// .sync_with_callback(sync_settings, |response| async move {
|
||||||
/// let channel = sync_channel;
|
/// let channel = sync_channel;
|
||||||
///
|
///
|
||||||
/// for (room_id, room) in response.rooms.join {
|
/// for (room_id, room) in response.rooms.join {
|
||||||
/// for event in room.timeline.events {
|
/// for event in room.timeline.events {
|
||||||
/// if let Ok(e) = event.deserialize() {
|
/// channel.send(event).await.unwrap();
|
||||||
/// channel.send(e).await;
|
|
||||||
/// }
|
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue