31 lines
1.3 KiB
Dart
Raw Normal View History

2021-07-26 11:51:39 +08:00
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
2021-09-04 16:53:58 +08:00
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace-infra/workspace_create.pb.dart';
2021-07-26 11:51:39 +08:00
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
2021-09-04 16:53:58 +08:00
export 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
2021-07-26 11:51:39 +08:00
abstract class IUser {
2021-09-04 16:53:58 +08:00
UserProfile get user;
Future<Either<UserProfile, UserError>> fetchUserProfile(String userId);
2021-07-26 13:51:41 +08:00
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces();
Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId);
2021-07-26 11:51:39 +08:00
Future<Either<Unit, UserError>> signOut();
Future<Either<Unit, UserError>> initUser();
2021-07-26 11:51:39 +08:00
}
2021-07-30 08:43:10 +08:00
2021-10-11 13:15:41 +08:00
typedef UserProfileUpdateCallback = void Function(Either<UserProfile, UserError>);
typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
2021-10-11 13:15:41 +08:00
typedef WorkspacesUpdatedCallback = void Function(Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
2021-10-11 13:15:41 +08:00
abstract class IUserListener {
void start();
void setProfileCallback(UserProfileUpdateCallback profileCallback);
void setAuthCallback(AuthChangedCallback authCallback);
void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
2021-07-30 08:43:10 +08:00
2021-10-11 13:15:41 +08:00
Future<void> stop();
2021-07-30 08:43:10 +08:00
}