2021-07-26 11:51:39 +08:00
|
|
|
import 'package:dartz/dartz.dart';
|
2021-11-08 23:15:29 +08:00
|
|
|
import 'package:flowy_infra/notifier.dart';
|
2021-07-26 11:51:39 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
2021-12-05 14:04:25 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
|
2021-12-10 22:48:30 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_create.pb.dart';
|
2021-12-06 14:41:09 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
|
2021-07-26 11:51:39 +08:00
|
|
|
export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
2021-12-05 14:04:25 +08:00
|
|
|
export 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
|
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();
|
2021-09-25 21:47:02 +08:00
|
|
|
Future<Either<Unit, UserError>> initUser();
|
2021-07-26 11:51:39 +08:00
|
|
|
}
|
2021-07-30 08:43:10 +08:00
|
|
|
|
2021-11-08 23:15:29 +08:00
|
|
|
typedef UserProfileUpdatedNotifierValue = Either<UserProfile, UserError>;
|
|
|
|
typedef AuthNotifierValue = Either<Unit, UserError>;
|
|
|
|
typedef WorkspaceUpdatedNotifierValue = Either<List<Workspace>, WorkspaceError>;
|
2021-09-08 13:50:20 +08:00
|
|
|
|
2021-10-11 13:15:41 +08:00
|
|
|
abstract class IUserListener {
|
|
|
|
void start();
|
2021-11-08 23:15:29 +08:00
|
|
|
|
|
|
|
PublishNotifier<UserProfileUpdatedNotifierValue> get profileUpdatedNotifier;
|
|
|
|
PublishNotifier<AuthNotifierValue> get authDidChangedNotifier;
|
|
|
|
PublishNotifier<WorkspaceUpdatedNotifierValue> get workspaceUpdatedNotifier;
|
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
|
|
|
}
|