mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
31 lines
873 B
Dart
31 lines
873 B
Dart
import 'dart:async';
|
|
|
|
import 'package:bloc/bloc.dart';
|
|
import 'package:equatable/equatable.dart';
|
|
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
|
|
import 'package:syncrow_web/services/devices_mang_api.dart';
|
|
|
|
part 'gate_way_event.dart';
|
|
part 'gate_way_state.dart';
|
|
|
|
class GateWayBloc extends Bloc<GateWayEvent, GateWayState> {
|
|
GateWayBloc() : super(GateWayInitial()) {
|
|
on<GateWayFetch>((event, emit) {});
|
|
on<GatWayById>(_getGatWayById);
|
|
}
|
|
|
|
FutureOr<void> _getGatWayById(
|
|
GatWayById event, Emitter<GateWayState> emit) async {
|
|
emit(GatewayLoadingState());
|
|
try {
|
|
List<DeviceModel> devicesList =
|
|
await DevicesManagementApi.getDevicesByGatewayId(event.getWayId);
|
|
|
|
emit(UpdateGatewayState(list: devicesList));
|
|
} catch (e) {
|
|
emit(ErrorState(message: e.toString()));
|
|
return;
|
|
}
|
|
}
|
|
}
|