Skip to content

Commit bfd5d89

Browse files
committed
feat(content_management): add data update event to EditSourceBloc
- Implement EditSourceDataUpdated event to update BLoC with latest shared data - Add handler for EditSourceDataUpdated event in EditSourceBloc - Update state with new countries and languages data when event is triggered
1 parent 981fc2b commit bfd5d89

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/content_management/bloc/edit_source/edit_source_bloc.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
3232
on<EditSourceHeadquartersChanged>(_onHeadquartersChanged);
3333
on<EditSourceStatusChanged>(_onStatusChanged);
3434
on<EditSourceSubmitted>(_onSubmitted);
35+
on<EditSourceDataUpdated>(_onDataUpdated);
3536
}
3637

3738
final DataRepository<Source> _sourcesRepository;
@@ -195,4 +196,11 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
195196
);
196197
}
197198
}
199+
200+
void _onDataUpdated(
201+
EditSourceDataUpdated event,
202+
Emitter<EditSourceState> emit,
203+
) {
204+
emit(state.copyWith(countries: event.countries, languages: event.languages));
205+
}
198206
}

lib/content_management/bloc/edit_source/edit_source_event.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,17 @@ final class EditSourceStatusChanged extends EditSourceEvent {
8686
final class EditSourceSubmitted extends EditSourceEvent {
8787
const EditSourceSubmitted();
8888
}
89+
90+
/// Event to update the BLoC with the latest shared data.
91+
final class EditSourceDataUpdated extends EditSourceEvent {
92+
const EditSourceDataUpdated({
93+
required this.countries,
94+
required this.languages,
95+
});
96+
97+
final List<Country> countries;
98+
final List<Language> languages;
99+
100+
@override
101+
List<Object?> get props => [countries, languages];
102+
}

0 commit comments

Comments
 (0)