mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-31 01:54:37 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			624 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			624 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use lib_dispatch::prelude::*;
 | |
| use lib_dispatch::runtime::tokio_default_runtime;
 | |
| use std::sync::Arc;
 | |
| 
 | |
| pub async fn hello() -> String {
 | |
|   "say hello".to_string()
 | |
| }
 | |
| 
 | |
| #[tokio::test]
 | |
| async fn test() {
 | |
|   let event = "1";
 | |
|   let runtime = tokio_default_runtime().unwrap();
 | |
|   let dispatch = Arc::new(AFPluginDispatcher::construct(runtime, || {
 | |
|     vec![AFPlugin::new().event(event, hello)]
 | |
|   }));
 | |
|   let request = AFPluginRequest::new(event);
 | |
|   let _ = AFPluginDispatcher::async_send_with_callback(dispatch.clone(), request, |resp| {
 | |
|     Box::pin(async move {
 | |
|       dbg!(&resp);
 | |
|     })
 | |
|   })
 | |
|   .await;
 | |
| 
 | |
|   std::mem::forget(dispatch);
 | |
| }
 | 
