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