Crates.io | simple_pubsub |
lib.rs | simple_pubsub |
version | 0.5.3 |
source | src |
created_at | 2022-01-22 19:30:53.550941 |
updated_at | 2022-02-13 20:25:12.727643 |
description | A simple pubsub use dashmap and mpsc channel. |
homepage | https://github.com/tyrchen/utility-belt |
repository | https://github.com/tyrchen/utility-belt |
max_upload_size | |
id | 519279 |
size | 8,740 |
Usage:
let topic = "lobby";
let broadcaster: Arc<Broadcaster<String>> = Arc::new(Broadcaster::default());
let (id, mut receiver) = broadcaster.clone().subscribe(topic);
broadcaster.publish(topic, Arc::new("hello world".into()));
let data = receiver.recv().await.unwrap();
assert!(id > 0);
assert_eq!(data.as_ref(), "hello world");