mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[code gen]: return unit if there is no ouput
This commit is contained in:
parent
7d342df1f1
commit
1f42fa557b
@ -6,4 +6,6 @@ abstract class IAuth {
|
|||||||
Future<Either<UserDetail, UserError>> signIn(String? email, String? password);
|
Future<Either<UserDetail, UserError>> signIn(String? email, String? password);
|
||||||
Future<Either<UserDetail, UserError>> signUp(
|
Future<Either<UserDetail, UserError>> signUp(
|
||||||
String? name, String? password, String? email);
|
String? name, String? password, String? email);
|
||||||
|
|
||||||
|
Future<Either<Unit, UserError>> signOut();
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,8 @@ class AuthRepository {
|
|||||||
|
|
||||||
return UserEventSignUp(request).send();
|
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) {
|
String? name, String? password, String? email) {
|
||||||
return repo.signUp(name: name, password: password, email: 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 {
|
class UserEventSignOut {
|
||||||
UserEventSignOut();
|
UserEventSignOut();
|
||||||
|
|
||||||
Future<Either<Uint8List, UserError>> send() {
|
Future<Either<Unit, UserError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = UserEvent.SignOut.toString();
|
..event = UserEvent.SignOut.toString();
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||||
(bytes) => left(bytes),
|
(bytes) => left(unit),
|
||||||
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
(errBytes) => right(UserError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,14 @@ impl EventTemplate {
|
|||||||
self.tera_context
|
self.tera_context
|
||||||
.insert("has_input", &ctx.input_deserializer.is_some());
|
.insert("has_input", &ctx.input_deserializer.is_some());
|
||||||
match ctx.input_deserializer {
|
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),
|
Some(ref input) => self.tera_context.insert("input_deserializer", input),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tera_context
|
self.tera_context
|
||||||
.insert("has_output", &ctx.output_deserializer.is_some());
|
.insert("has_output", &ctx.output_deserializer.is_some());
|
||||||
match ctx.output_deserializer {
|
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),
|
Some(ref output) => self.tera_context.insert("output_deserializer", output),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class {{ event_class }} {
|
|||||||
{%- if has_output %}
|
{%- if has_output %}
|
||||||
(okBytes) => left({{ output_deserializer }}.fromBuffer(okBytes)),
|
(okBytes) => left({{ output_deserializer }}.fromBuffer(okBytes)),
|
||||||
{%- else %}
|
{%- else %}
|
||||||
(bytes) => left(bytes),
|
(bytes) => left(unit),
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
(errBytes) => right({{ error_deserializer }}.fromBuffer(errBytes)),
|
(errBytes) => right({{ error_deserializer }}.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user