module.rs 550 B

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