Init mailbox feature add presentation layer
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class BaseController extends GetxController {
|
||||
final viewState = Rx<Either<Failure, Success>>(Right(UIState.idle));
|
||||
|
||||
void consumeState(Stream<Either<Failure, Success>> newStateStream) async {
|
||||
newStateStream.listen(
|
||||
(state) => onData(state),
|
||||
onError: (error) => onError(error),
|
||||
onDone: () => onDone()
|
||||
);
|
||||
}
|
||||
|
||||
void onData(Either<Failure, Success> newState) {
|
||||
viewState.value = newState;
|
||||
}
|
||||
|
||||
void onError(dynamic error);
|
||||
|
||||
void onDone();
|
||||
}
|
||||
Reference in New Issue
Block a user