2021-11-19 06:38:11 +00:00
|
|
|
use lib_dispatch::prelude::*;
|
2021-09-04 07:12:53 +00:00
|
|
|
use std::sync::Arc;
|
2021-06-29 08:52:29 +00:00
|
|
|
|
|
|
|
pub async fn hello() -> String { "say hello".to_string() }
|
|
|
|
|
2021-07-02 12:45:51 +00:00
|
|
|
#[tokio::test]
|
2021-09-04 07:12:53 +00:00
|
|
|
async fn test() {
|
2021-09-17 11:03:46 +00:00
|
|
|
env_logger::init();
|
|
|
|
|
2021-06-29 08:52:29 +00:00
|
|
|
let event = "1";
|
2021-09-17 11:03:46 +00:00
|
|
|
let dispatch = Arc::new(EventDispatch::construct(|| vec![Module::new().event(event, hello)]));
|
2021-07-08 05:47:11 +00:00
|
|
|
let request = ModuleRequest::new(event);
|
2021-09-04 07:12:53 +00:00
|
|
|
let _ = EventDispatch::async_send_with_callback(dispatch.clone(), request, |resp| {
|
2021-07-08 05:47:11 +00:00
|
|
|
Box::pin(async move {
|
|
|
|
dbg!(&resp);
|
|
|
|
})
|
|
|
|
})
|
2021-07-07 14:24:26 +00:00
|
|
|
.await;
|
2021-09-04 07:12:53 +00:00
|
|
|
|
|
|
|
std::mem::forget(dispatch);
|
2021-06-29 08:52:29 +00:00
|
|
|
}
|