Skip to content

Commit 981fc2b

Browse files
committed
feat(content_management): add data update event for create source BLoC
- Implement CreateSourceDataUpdated event to update BLoC with shared data - Add handler for CreateSourceDataUpdated event in CreateSourceBloc - Update countries and languages in CreateSourceState using new event data
1 parent 341c97b commit 981fc2b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/content_management/bloc/create_source/create_source_bloc.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
3030
on<CreateSourceHeadquartersChanged>(_onHeadquartersChanged);
3131
on<CreateSourceStatusChanged>(_onStatusChanged);
3232
on<CreateSourceSubmitted>(_onSubmitted);
33+
on<CreateSourceDataUpdated>(_onDataUpdated);
3334
}
3435

3536
final DataRepository<Source> _sourcesRepository;
@@ -130,4 +131,11 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
130131
);
131132
}
132133
}
134+
135+
void _onDataUpdated(
136+
CreateSourceDataUpdated event,
137+
Emitter<CreateSourceState> emit,
138+
) {
139+
emit(state.copyWith(countries: event.countries, languages: event.languages));
140+
}
133141
}

lib/content_management/bloc/create_source/create_source_event.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,17 @@ final class CreateSourceStatusChanged extends CreateSourceEvent {
7070
final class CreateSourceSubmitted extends CreateSourceEvent {
7171
const CreateSourceSubmitted();
7272
}
73+
74+
/// Event to update the BLoC with the latest shared data.
75+
final class CreateSourceDataUpdated extends CreateSourceEvent {
76+
const CreateSourceDataUpdated({
77+
required this.countries,
78+
required this.languages,
79+
});
80+
81+
final List<Country> countries;
82+
final List<Language> languages;
83+
84+
@override
85+
List<Object?> get props => [countries, languages];
86+
}

0 commit comments

Comments
 (0)