i_user.dart 1.3 KB

123456789101112131415161718192021222324252627282930
  1. import 'package:dartz/dartz.dart';
  2. import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
  4. import 'package:flowy_sdk/protobuf/flowy-workspace-infra/workspace_create.pb.dart';
  5. import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
  6. export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
  7. export 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
  8. abstract class IUser {
  9. UserProfile get user;
  10. Future<Either<UserProfile, UserError>> fetchUserProfile(String userId);
  11. Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces();
  12. Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId);
  13. Future<Either<Unit, UserError>> signOut();
  14. Future<Either<Unit, UserError>> initUser();
  15. }
  16. typedef UserProfileUpdateCallback = void Function(Either<UserProfile, UserError>);
  17. typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
  18. typedef WorkspacesUpdatedCallback = void Function(Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
  19. abstract class IUserListener {
  20. void start();
  21. void setProfileCallback(UserProfileUpdateCallback profileCallback);
  22. void setAuthCallback(AuthChangedCallback authCallback);
  23. void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
  24. Future<void> stop();
  25. }