mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
29 lines
755 B
Dart
29 lines
755 B
Dart
|
|
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()));
|
|
}
|
|
}
|
|
|
|
}
|