mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-31 01:54:37 +00:00 
			
		
		
		
	
		
			
	
	
		
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
|   | class {{ event_class }} { | ||
|  | {%- if has_input  %} | ||
|  |      {{ input_deserializer }} request; | ||
|  |      {{ event_class }}(this.request); | ||
|  | {%- else %} | ||
|  |     {{ event_class }}(); | ||
|  | {%- endif %} | ||
|  | 
 | ||
|  |     Future<Either<{{ output_deserializer }}, {{ error_deserializer }}>> send() { | ||
|  | 
 | ||
|  | {%- if has_input  %} | ||
|  |     final request = FFIRequest.create() | ||
|  |           ..event = {{ event }}.toString() | ||
|  |           ..payload = requestToBytes(this.request); | ||
|  | 
 | ||
|  |     return Dispatch.asyncRequest(request) | ||
|  |         .then((bytesResult) => bytesResult.fold( | ||
|  | 
 | ||
|  |         {%- if has_output  %} | ||
|  |            (okBytes) => left({{ output_deserializer }}.fromBuffer(okBytes)), | ||
|  |         {%- else %} | ||
|  |            (bytes) => left(unit), | ||
|  |         {%- endif %} | ||
|  |            (errBytes) => right({{ error_deserializer }}.fromBuffer(errBytes)), | ||
|  |         )); | ||
|  | 
 | ||
|  | {%- else %} | ||
|  |      final request = FFIRequest.create() | ||
|  |         ..event = {{ event }}.toString(); | ||
|  |         {%- if has_input  %} | ||
|  |         ..payload = bytes; | ||
|  |         {%- endif %} | ||
|  | 
 | ||
|  |      return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( | ||
|  |      {%- if has_output  %} | ||
|  |         (okBytes) => left({{ output_deserializer }}.fromBuffer(okBytes)), | ||
|  |      {%- else %} | ||
|  |         (bytes) => left(unit), | ||
|  |      {%- endif %} | ||
|  |         (errBytes) => right({{ error_deserializer }}.fromBuffer(errBytes)), | ||
|  |       )); | ||
|  | {%- endif %} | ||
|  |     } | ||
|  | } | ||
|  | 
 |