module_event.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. use crate::helper::*;
  2. use flowy_sys::prelude::*;
  3. pub async fn no_params() -> String { "no params function call".to_string() }
  4. pub async fn one_params(_s: String) -> String { "one params function call".to_string() }
  5. pub async fn two_params(_s1: String, _s2: String) -> String { "two params function call".to_string() }
  6. #[test]
  7. fn test_init() {
  8. setup_env();
  9. let no_params_command = "no params".to_string();
  10. let one_params_command = "one params".to_string();
  11. let two_params_command = "two params".to_string();
  12. let modules = vec![Module::new()
  13. .event(no_params_command.clone(), no_params)
  14. .event(one_params_command.clone(), one_params)
  15. .event(two_params_command.clone(), two_params)];
  16. init_system(modules, || {
  17. let request = EventRequest::new(no_params_command);
  18. let stream_data = StreamData::new(1, Some(request)).with_callback(Box::new(|_config, response| {
  19. log::info!("async resp: {:?}", response);
  20. }));
  21. let resp = sync_send(stream_data);
  22. log::info!("sync resp: {:?}", resp);
  23. stop_system();
  24. });
  25. }