mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-09-13 10:38:10 +00:00

* chore: fix wanrings * chore: remove protobuf ref in flowy-error-code * chore: remove protobuf ref in lib-ws * refactor: remove protobuf trait in flowy http model * refactor: remove flowy-error-code crate Co-authored-by: nathan <nathan@appflowy.io>
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 %}
|
|
}
|
|
}
|
|
|