mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 06:37:14 -04:00
[code gen]: return unit if there is no ouput
This commit is contained in:
parent
7d342df1f1
commit
1f42fa557b
6 changed files with 16 additions and 5 deletions
|
@ -6,4 +6,6 @@ abstract class IAuth {
|
|||
Future<Either<UserDetail, UserError>> signIn(String? email, String? password);
|
||||
Future<Either<UserDetail, UserError>> signUp(
|
||||
String? name, String? password, String? email);
|
||||
|
||||
Future<Either<Unit, UserError>> signOut();
|
||||
}
|
||||
|
|
|
@ -27,4 +27,8 @@ class AuthRepository {
|
|||
|
||||
return UserEventSignUp(request).send();
|
||||
}
|
||||
|
||||
Future<Either<Unit, UserError>> signOut() {
|
||||
return UserEventSignOut().send();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,4 +36,9 @@ class AuthImpl extends IAuth {
|
|||
String? name, String? password, String? email) {
|
||||
return repo.signUp(name: name, password: password, email: email);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Unit, UserError>> signOut() {
|
||||
return repo.signOut();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@ class UserEventSignUp {
|
|||
class UserEventSignOut {
|
||||
UserEventSignOut();
|
||||
|
||||
Future<Either<Uint8List, UserError>> send() {
|
||||
Future<Either<Unit, UserError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignOut.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(bytes),
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -40,14 +40,14 @@ impl EventTemplate {
|
|||
self.tera_context
|
||||
.insert("has_input", &ctx.input_deserializer.is_some());
|
||||
match ctx.input_deserializer {
|
||||
None => self.tera_context.insert("input_deserializer", "Uint8List"),
|
||||
None => self.tera_context.insert("input_deserializer", "Unit"),
|
||||
Some(ref input) => self.tera_context.insert("input_deserializer", input),
|
||||
}
|
||||
|
||||
self.tera_context
|
||||
.insert("has_output", &ctx.output_deserializer.is_some());
|
||||
match ctx.output_deserializer {
|
||||
None => self.tera_context.insert("output_deserializer", "Uint8List"),
|
||||
None => self.tera_context.insert("output_deserializer", "Unit"),
|
||||
Some(ref output) => self.tera_context.insert("output_deserializer", output),
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class {{ event_class }} {
|
|||
{%- if has_output %}
|
||||
(okBytes) => left({{ output_deserializer }}.fromBuffer(okBytes)),
|
||||
{%- else %}
|
||||
(bytes) => left(bytes),
|
||||
(bytes) => left(unit),
|
||||
{%- endif %}
|
||||
(errBytes) => right({{ error_deserializer }}.fromBuffer(errBytes)),
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue