diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-10-25 21:59:10 -0400 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-10-25 21:59:10 -0400 |
commit | ae2ab2da72b9d5d6d08bb9813c1b798bbfa5da7b (patch) | |
tree | 54507ba5afd03011a9ea32bc02758861a8bb6392 /ipfs-api/examples | |
parent | 4ea3bc9d4a3d62574800bf4aa1e7c28884ef9385 (diff) |
limit number of message in pubsub example
Diffstat (limited to 'ipfs-api/examples')
-rw-r--r-- | ipfs-api/examples/pubsub.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/ipfs-api/examples/pubsub.rs b/ipfs-api/examples/pubsub.rs index bc7d124..23b1dc6 100644 --- a/ipfs-api/examples/pubsub.rs +++ b/ipfs-api/examples/pubsub.rs @@ -32,17 +32,12 @@ fn main() { let timer = Timer::default(); let publish = timer .interval(Duration::from_secs(1)) - .map_err(|_| { - response::Error::from("timeout error") - }) + .map_err(|_| response::Error::from("timeout error")) .for_each(move |_| { println!(""); println!("publishing message..."); - client.pubsub_pub(TOPIC, "Hello World!").then(|_| { - println!("success"); - Ok(()) - }) + client.pubsub_pub(TOPIC, "Hello World!") }); println!(""); @@ -63,7 +58,7 @@ fn main() { println!(""); println!("waiting for messages on ({})...", TOPIC); event_loop - .run(req.for_each(|msg| { + .run(req.take(5).for_each(|msg| { println!(""); println!("received ({:?})", msg); |