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

28 lines
618 B
Rust
Raw Normal View History

use std::rc::Rc;
use lib_dispatch::prelude::*;
use lib_dispatch::runtime::AFPluginRuntime;
2022-01-23 04:14:00 +00:00
pub async fn hello() -> String {
"say hello".to_string()
2022-01-23 04:14:00 +00:00
}
#[tokio::test]
2021-09-04 07:12:53 +00:00
async fn test() {
let event = "1";
let runtime = Rc::new(AFPluginRuntime::new().unwrap());
let dispatch = Rc::new(AFPluginDispatcher::new(
runtime,
vec![AFPlugin::new().event(event, hello)],
));
let request = AFPluginRequest::new(event);
let _ = AFPluginDispatcher::async_send_with_callback(dispatch.as_ref(), request, |resp| {
Box::pin(async move {
dbg!(&resp);
})
})
.await;
2021-09-04 07:12:53 +00:00
std::mem::forget(dispatch);
}