dart_ffi.rs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. use crate::helper::*;
  2. use flowy_sys::{dart_ffi::*, 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_dart(modules, || {
  17. let request = EventRequest::new(no_params_command);
  18. let stream_data = StreamData::new(
  19. 1,
  20. Some(request),
  21. Box::new(|config, response| {
  22. log::info!("😁😁😁 {:?}", response);
  23. }),
  24. );
  25. send(stream_data);
  26. FlowySystem::current().stop();
  27. });
  28. }