i_user.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233
  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/errors.pb.dart';
  5. import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
  6. export 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
  7. export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
  8. export 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
  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. }
  16. typedef UserProfileUpdateCallback = void Function(
  17. Either<UserProfile, UserError>);
  18. typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
  19. typedef WorkspacesUpdatedCallback = void Function(
  20. Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
  21. abstract class IUserWatch {
  22. void startWatching();
  23. void setProfileCallback(UserProfileUpdateCallback profileCallback);
  24. void setAuthCallback(AuthChangedCallback authCallback);
  25. void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
  26. Future<void> stopWatching();
  27. }