i_user.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132
  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(Either<UserProfile, UserError>);
  18. typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
  19. typedef WorkspacesUpdatedCallback = void Function(Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
  20. abstract class IUserListener {
  21. void start();
  22. void setProfileCallback(UserProfileUpdateCallback profileCallback);
  23. void setAuthCallback(AuthChangedCallback authCallback);
  24. void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
  25. Future<void> stop();
  26. }