2022-01-23 12:14:00 +08:00

24 lines
550 B
Rust

use lib_dispatch::prelude::*;
use std::sync::Arc;
pub async fn hello() -> String {
"say hello".to_string()
}
#[tokio::test]
async fn test() {
env_logger::init();
let event = "1";
let dispatch = Arc::new(EventDispatcher::construct(|| vec![Module::new().event(event, hello)]));
let request = ModuleRequest::new(event);
let _ = EventDispatcher::async_send_with_callback(dispatch.clone(), request, |resp| {
Box::pin(async move {
dbg!(&resp);
})
})
.await;
std::mem::forget(dispatch);
}