i_user.dart 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. import 'package:dartz/dartz.dart';
  2. import 'package:flowy_infra/notifier.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
  4. import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
  5. import 'package:flowy_sdk/protobuf/flowy-workspace-infra/workspace_create.pb.dart';
  6. import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
  7. export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
  8. export 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
  9. abstract class IUser {
  10. UserProfile get user;
  11. Future<Either<UserProfile, UserError>> fetchUserProfile(String userId);
  12. Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces();
  13. Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId);
  14. Future<Either<Unit, UserError>> signOut();
  15. Future<Either<Unit, UserError>> initUser();
  16. }
  17. typedef UserProfileUpdatedNotifierValue = Either<UserProfile, UserError>;
  18. typedef AuthNotifierValue = Either<Unit, UserError>;
  19. typedef WorkspaceUpdatedNotifierValue = Either<List<Workspace>, WorkspaceError>;
  20. abstract class IUserListener {
  21. void start();
  22. PublishNotifier<UserProfileUpdatedNotifierValue> get profileUpdatedNotifier;
  23. PublishNotifier<AuthNotifierValue> get authDidChangedNotifier;
  24. PublishNotifier<WorkspaceUpdatedNotifierValue> get workspaceUpdatedNotifier;
  25. Future<void> stop();
  26. }