added more blocs
This commit is contained in:
@@ -1,10 +1,27 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:tunas/repositories/account/account_repository.dart';
|
||||
import 'package:tunas/repositories/account/models/budget.dart';
|
||||
|
||||
part 'budget_event.dart';
|
||||
part 'budget_state.dart';
|
||||
|
||||
class BudgetBloc extends Bloc<BudgetEvent, BudgetState> {
|
||||
BudgetBloc(super.initialState);
|
||||
final AccountRepository _accountRepository;
|
||||
|
||||
BudgetBloc({required AccountRepository accountRepository}) : _accountRepository = accountRepository, super(const BudgetState()) {
|
||||
on<BudgetsLoad>(_onBudgetsLoad);
|
||||
|
||||
_accountRepository
|
||||
.getBudgetsStream()
|
||||
.listen((budgets) => add(BudgetsLoad(budgets)));
|
||||
}
|
||||
|
||||
_onBudgetsLoad(
|
||||
BudgetsLoad event, Emitter<BudgetState> emit
|
||||
) {
|
||||
emit(state.copyWith(
|
||||
budgets: event.budgets,
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user