mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
ac device
This commit is contained in:
28
lib/pages/device_managment/ac/bloc/ac_bloc.dart
Normal file
28
lib/pages/device_managment/ac/bloc/ac_bloc.dart
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_state.dart';
|
||||
import 'package:syncrow_web/services/devices_mang_api.dart';
|
||||
|
||||
|
||||
class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
|
||||
AcBloc() : super(AcsInitialState()) {
|
||||
on<AcFetchDeviceStatus>(_onFetchAcStatus);
|
||||
|
||||
}
|
||||
|
||||
FutureOr<void> _onFetchAcStatus(
|
||||
AcFetchDeviceStatus event, Emitter<AcsState> emit) async {
|
||||
emit(AcsLoadingState());
|
||||
try {
|
||||
final status =
|
||||
await DevicesManagementApi().getDeviceStatus(event.deviceId);
|
||||
emit(ACStatusLoaded(status));
|
||||
} catch (e) {
|
||||
emit(AcsFailedState( error: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user