i_user.dart 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  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. Future<Either<Unit, UserError>> initUser();
  16. }
  17. typedef UserProfileUpdateCallback = void Function(
  18. Either<UserProfile, UserError>);
  19. typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
  20. typedef WorkspacesUpdatedCallback = void Function(
  21. Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
  22. abstract class IUserWatch {
  23. void startWatching();
  24. void setProfileCallback(UserProfileUpdateCallback profileCallback);
  25. void setAuthCallback(AuthChangedCallback authCallback);
  26. void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
  27. Future<void> stopWatching();
  28. }