i_user.dart 1.2 KB

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