AppFlowy/frontend/rust-lib/lib-dispatch/tests/api/module.rs

22 lines
546 B
Rust
Raw Normal View History

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