refactor: Use transformers for blocs

This commit is contained in:
Inex Code 2024-01-31 16:17:27 +04:00
parent 21c0e200a9
commit 1ba8f324fe
5 changed files with 29 additions and 0 deletions

View file

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -19,33 +20,43 @@ class BackupsBloc extends Bloc<BackupsEvent, BackupsState> {
BackupsBloc() : super(BackupsInitial()) {
on<BackupsServerLoaded>(
_loadState,
transformer: droppable(),
);
on<BackupsServerReset>(
_resetState,
transformer: droppable(),
);
on<BackupsStateChanged>(
_updateState,
transformer: droppable(),
);
on<InitializeBackupsRepository>(
_initializeRepository,
transformer: droppable(),
);
on<ForceSnapshotListUpdate>(
_forceSnapshotListUpdate,
transformer: droppable(),
);
on<CreateBackups>(
_createBackups,
transformer: sequential(),
);
on<RestoreBackup>(
_restoreBackup,
transformer: sequential(),
);
on<SetAutobackupPeriod>(
_setAutobackupPeriod,
transformer: restartable(),
);
on<SetAutobackupQuotas>(
_setAutobackupQuotas,
transformer: restartable(),
);
on<ForgetSnapshot>(
_forgetSnapshot,
transformer: sequential(),
);
final connectionRepository = getIt<ApiConnectionRepository>();

View file

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:selfprivacy/config/get_it_config.dart';
@ -17,12 +18,15 @@ class ServerJobsBloc extends Bloc<ServerJobsEvent, ServerJobsState> {
) {
on<ServerJobsListChanged>(
_mapServerJobsListChangedToState,
transformer: sequential(),
);
on<RemoveServerJob>(
_mapRemoveServerJobToState,
transformer: sequential(),
);
on<RemoveAllFinishedJobs>(
_mapRemoveAllFinishedJobsToState,
transformer: droppable(),
);
final apiConnectionRepository = getIt<ApiConnectionRepository>();

View file

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -14,15 +15,19 @@ class ServicesBloc extends Bloc<ServicesEvent, ServicesState> {
ServicesBloc() : super(ServicesInitial()) {
on<ServicesListUpdate>(
_updateList,
transformer: sequential(),
);
on<ServicesReload>(
_reload,
transformer: droppable(),
);
on<ServiceRestart>(
_restart,
transformer: sequential(),
);
on<ServiceMove>(
_move,
transformer: sequential(),
);
final connectionRepository = getIt<ApiConnectionRepository>();

View file

@ -81,6 +81,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.1.2"
bloc_concurrency:
dependency: "direct main"
description:
name: bloc_concurrency
sha256: d945b33641a3c3f12fa12a1437e77f784444dd9a3a66a3a4f5aaa6e049154d36
url: "https://pub.dev"
source: hosted
version: "0.2.3"
boolean_selector:
dependency: transitive
description:

View file

@ -11,6 +11,7 @@ dependencies:
animations: ^2.0.8
auto_route: ^7.8.4
auto_size_text: ^3.0.0
bloc_concurrency: ^0.2.3
crypt: ^4.3.1
cubit_form: ^2.0.1
device_info_plus: ^9.1.1