mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Update RealtimeDeviceChangesBloc to handle loading and failure states
This commit is contained in:
@ -25,10 +25,11 @@ class RealtimeDeviceChangesBloc
|
|||||||
onData: (data) {
|
onData: (data) {
|
||||||
final currentState = state;
|
final currentState = state;
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
|
status: RealtimeDeviceChangesStatus.loaded,
|
||||||
deviceStatusList: [
|
deviceStatusList: [
|
||||||
...currentState.deviceStatusList.where((device) =>
|
...currentState.deviceStatusList.where((device) =>
|
||||||
!data.any((newDevice) => newDevice.code == device.code)),
|
!data.any((newDevice) => newDevice.code == device.code)),
|
||||||
...data,
|
...data,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -36,7 +37,7 @@ class RealtimeDeviceChangesBloc
|
|||||||
},
|
},
|
||||||
onError: (error, _) => emit(
|
onError: (error, _) => emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
status: RealtimeDeviceChangesStatus.error,
|
status: RealtimeDeviceChangesStatus.failure,
|
||||||
errorMessage: '$error',
|
errorMessage: '$error',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
part of 'realtime_device_changes_bloc.dart';
|
part of 'realtime_device_changes_bloc.dart';
|
||||||
|
|
||||||
enum RealtimeDeviceChangesStatus { initial, loading, loaded, error }
|
enum RealtimeDeviceChangesStatus { initial, loaded, failure }
|
||||||
|
|
||||||
final class RealtimeDeviceChangesState extends Equatable {
|
final class RealtimeDeviceChangesState extends Equatable {
|
||||||
const RealtimeDeviceChangesState({
|
const RealtimeDeviceChangesState({
|
||||||
|
Reference in New Issue
Block a user