2022-01-13 11:16:26 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-core-data-model/view.pb.dart';
|
2021-07-24 09:57:17 +08:00
|
|
|
import 'package:dartz/dartz.dart';
|
2021-10-31 17:24:55 +08:00
|
|
|
import 'package:flowy_infra/notifier.dart';
|
2021-12-14 18:04:51 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
2021-07-23 23:56:59 +08:00
|
|
|
|
2021-12-14 18:04:51 +08:00
|
|
|
typedef ViewUpdatedCallback = void Function(Either<View, FlowyError>);
|
2021-07-23 23:56:59 +08:00
|
|
|
|
2021-12-14 18:04:51 +08:00
|
|
|
typedef DeleteNotifierValue = Either<View, FlowyError>;
|
|
|
|
typedef UpdateNotifierValue = Either<View, FlowyError>;
|
|
|
|
typedef RestoreNotifierValue = Either<View, FlowyError>;
|
2021-10-31 17:24:55 +08:00
|
|
|
|
2021-07-24 09:57:17 +08:00
|
|
|
abstract class IView {
|
2021-10-12 13:07:41 +08:00
|
|
|
View get view;
|
|
|
|
|
2021-12-14 18:04:51 +08:00
|
|
|
Future<Either<Unit, FlowyError>> delete();
|
2021-10-12 13:07:41 +08:00
|
|
|
|
2021-12-14 18:04:51 +08:00
|
|
|
Future<Either<View, FlowyError>> rename(String newName);
|
2021-10-20 22:19:01 +08:00
|
|
|
|
2021-12-14 18:04:51 +08:00
|
|
|
Future<Either<Unit, FlowyError>> duplicate();
|
2021-07-24 09:57:17 +08:00
|
|
|
}
|
|
|
|
|
2021-10-12 13:07:41 +08:00
|
|
|
abstract class IViewListener {
|
2021-10-31 17:24:55 +08:00
|
|
|
void start();
|
|
|
|
|
|
|
|
PublishNotifier<UpdateNotifierValue> get updatedNotifier;
|
|
|
|
|
|
|
|
PublishNotifier<DeleteNotifierValue> get deletedNotifier;
|
|
|
|
|
|
|
|
PublishNotifier<RestoreNotifierValue> get restoredNotifier;
|
2021-07-23 22:42:44 +08:00
|
|
|
|
2021-10-12 13:07:41 +08:00
|
|
|
Future<void> stop();
|
2021-07-23 22:42:44 +08:00
|
|
|
}
|