module.rs 547 B

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