2021-07-26 11:51:39 +08:00
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
2021-09-04 16:53:58 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
2021-07-26 11:51:39 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
2021-07-26 13:51:41 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
2021-07-26 11:51:39 +08:00
|
|
|
|
2021-07-26 13:51:41 +08:00
|
|
|
export 'package:flowy_sdk/protobuf/flowy-workspace/workspace_create.pb.dart';
|
2021-07-26 11:51:39 +08:00
|
|
|
export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
|
2021-09-04 16:53:58 +08:00
|
|
|
export 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
2021-07-26 11:51:39 +08:00
|
|
|
|
|
|
|
abstract class IUser {
|
2021-09-04 16:53:58 +08:00
|
|
|
UserProfile get user;
|
|
|
|
Future<Either<UserProfile, UserError>> fetchUserProfile(String userId);
|
2021-07-26 13:51:41 +08:00
|
|
|
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces();
|
|
|
|
Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId);
|
2021-07-26 11:51:39 +08:00
|
|
|
Future<Either<Unit, UserError>> signOut();
|
|
|
|
}
|
2021-07-30 08:43:10 +08:00
|
|
|
|
2021-09-08 13:50:20 +08:00
|
|
|
typedef UserProfileUpdateCallback = void Function(
|
|
|
|
Either<UserProfile, UserError>);
|
|
|
|
|
|
|
|
typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
|
|
|
|
typedef WorkspacesUpdatedCallback = void Function(
|
|
|
|
Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
|
|
|
|
|
|
|
|
abstract class IUserWatch {
|
|
|
|
void startWatching();
|
|
|
|
void setProfileCallback(UserProfileUpdateCallback profileCallback);
|
|
|
|
void setAuthCallback(AuthChangedCallback authCallback);
|
|
|
|
void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
|
2021-07-30 08:43:10 +08:00
|
|
|
|
|
|
|
Future<void> stopWatching();
|
|
|
|
}
|