module.rs 542 B

123456789101112131415161718192021
  1. use lib_dispatch::prelude::*;
  2. use std::sync::Arc;
  3. pub async fn hello() -> String { "say hello".to_string() }
  4. #[tokio::test]
  5. async fn test() {
  6. env_logger::init();
  7. let event = "1";
  8. let dispatch = Arc::new(EventDispatch::construct(|| vec![Module::new().event(event, hello)]));
  9. let request = ModuleRequest::new(event);
  10. let _ = EventDispatch::async_send_with_callback(dispatch.clone(), request, |resp| {
  11. Box::pin(async move {
  12. dbg!(&resp);
  13. })
  14. })
  15. .await;
  16. std::mem::forget(dispatch);
  17. }