import 'package:bloc/bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';

part 'printer_event.dart';
part 'printer_state.dart';
part 'printer_bloc.freezed.dart';

@injectable
class PrinterBloc extends Bloc<PrinterEvent, PrinterState> {
  PrinterBloc() : super(PrinterState.initial()) {
    on<PrinterEvent>(_onPrinterEvent);
  }

  Future<void> _onPrinterEvent(PrinterEvent event, Emitter<PrinterState> emit) {
    return event.map(
      indexChanged: (e) async {
        emit(state.copyWith(index: e.index));
      },
    );
  }
}
