Files
tmail-flutter/lib/features/push_notification/presentation/controller/fcm_base_controller.dart
T

25 lines
745 B
Dart

import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/utils/app_logger.dart';
import 'package:dartz/dartz.dart';
abstract class FcmBaseController {
void consumeState(Stream<Either<Failure, Success>> newStateStream) {
newStateStream.listen(
_handleStateStream,
onError: (error, stackTrace) {
logError('FcmBaseController::consumeState():onError:error: $error | stackTrace: $stackTrace');
}
);
}
void _handleStateStream(Either<Failure, Success> newState) {
newState.fold(handleFailureViewState, handleSuccessViewState);
}
void handleFailureViewState(Failure failure);
void handleSuccessViewState(Success success);
}