Skip to content

Commit c89a9c6

Browse files
committed
refactor(content_management): introducing new, specific events for adding and updating items (HeadlineAdded, HeadlineUpdated, etc.). These events will carry the actual object, allowing the BLoC to update its list locally without a full refresh. I am also removing the old Create...Requested and Update...Requested events as they are now obsolete.
1 parent 690d35a commit c89a9c6

File tree

1 file changed

+39
-48
lines changed

1 file changed

+39
-48
lines changed

lib/content_management/bloc/content_management_event.dart

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,32 @@ final class LoadHeadlinesRequested extends ContentManagementEvent {
3838
List<Object?> get props => [startAfterId, limit];
3939
}
4040

41-
/// {@template create_headline_requested}
42-
/// Event to request creation of a new headline.
41+
/// {@template headline_added}
42+
/// Event to add a new headline to the local state.
4343
/// {@endtemplate}
44-
final class CreateHeadlineRequested extends ContentManagementEvent {
45-
/// {@macro create_headline_requested}
46-
const CreateHeadlineRequested(this.headline);
44+
final class HeadlineAdded extends ContentManagementEvent {
45+
/// {@macro headline_added}
46+
const HeadlineAdded(this.headline);
4747

48-
/// The headline to create.
48+
/// The headline that was added.
4949
final Headline headline;
5050

5151
@override
5252
List<Object?> get props => [headline];
5353
}
5454

55-
/// {@template update_headline_requested}
56-
/// Event to request update of an existing headline.
55+
/// {@template headline_updated}
56+
/// Event to update an existing headline in the local state.
5757
/// {@endtemplate}
58-
final class UpdateHeadlineRequested extends ContentManagementEvent {
59-
/// {@macro update_headline_requested}
60-
const UpdateHeadlineRequested({required this.id, required this.headline});
58+
final class HeadlineUpdated extends ContentManagementEvent {
59+
/// {@macro headline_updated}
60+
const HeadlineUpdated(this.headline);
6161

62-
/// The ID of the headline to update.
63-
final String id;
64-
65-
/// The updated headline data.
62+
/// The headline that was updated.
6663
final Headline headline;
6764

6865
@override
69-
List<Object?> get props => [id, headline];
66+
List<Object?> get props => [headline];
7067
}
7168

7269
/// {@template delete_headline_requested}
@@ -100,35 +97,32 @@ final class LoadCategoriesRequested extends ContentManagementEvent {
10097
List<Object?> get props => [startAfterId, limit];
10198
}
10299

103-
/// {@template create_category_requested}
104-
/// Event to request creation of a new category.
100+
/// {@template category_added}
101+
/// Event to add a new category to the local state.
105102
/// {@endtemplate}
106-
final class CreateCategoryRequested extends ContentManagementEvent {
107-
/// {@macro create_category_requested}
108-
const CreateCategoryRequested(this.category);
103+
final class CategoryAdded extends ContentManagementEvent {
104+
/// {@macro category_added}
105+
const CategoryAdded(this.category);
109106

110-
/// The category to create.
107+
/// The category that was added.
111108
final Category category;
112109

113110
@override
114111
List<Object?> get props => [category];
115112
}
116113

117-
/// {@template update_category_requested}
118-
/// Event to request update of an existing category.
114+
/// {@template category_updated}
115+
/// Event to update an existing category in the local state.
119116
/// {@endtemplate}
120-
final class UpdateCategoryRequested extends ContentManagementEvent {
121-
/// {@macro update_category_requested}
122-
const UpdateCategoryRequested({required this.id, required this.category});
123-
124-
/// The ID of the category to update.
125-
final String id;
117+
final class CategoryUpdated extends ContentManagementEvent {
118+
/// {@macro category_updated}
119+
const CategoryUpdated(this.category);
126120

127-
/// The updated category data.
121+
/// The category that was updated.
128122
final Category category;
129123

130124
@override
131-
List<Object?> get props => [id, category];
125+
List<Object?> get props => [category];
132126
}
133127

134128
/// {@template delete_category_requested}
@@ -162,35 +156,32 @@ final class LoadSourcesRequested extends ContentManagementEvent {
162156
List<Object?> get props => [startAfterId, limit];
163157
}
164158

165-
/// {@template create_source_requested}
166-
/// Event to request creation of a new source.
159+
/// {@template source_added}
160+
/// Event to add a new source to the local state.
167161
/// {@endtemplate}
168-
final class CreateSourceRequested extends ContentManagementEvent {
169-
/// {@macro create_source_requested}
170-
const CreateSourceRequested(this.source);
162+
final class SourceAdded extends ContentManagementEvent {
163+
/// {@macro source_added}
164+
const SourceAdded(this.source);
171165

172-
/// The source to create.
166+
/// The source that was added.
173167
final Source source;
174168

175169
@override
176170
List<Object?> get props => [source];
177171
}
178172

179-
/// {@template update_source_requested}
180-
/// Event to request update of an existing source.
173+
/// {@template source_updated}
174+
/// Event to update an existing source in the local state.
181175
/// {@endtemplate}
182-
final class UpdateSourceRequested extends ContentManagementEvent {
183-
/// {@macro update_source_requested}
184-
const UpdateSourceRequested({required this.id, required this.source});
185-
186-
/// The ID of the source to update.
187-
final String id;
176+
final class SourceUpdated extends ContentManagementEvent {
177+
/// {@macro source_updated}
178+
const SourceUpdated(this.source);
188179

189-
/// The updated source data.
180+
/// The source that was updated.
190181
final Source source;
191182

192183
@override
193-
List<Object?> get props => [id, source];
184+
List<Object?> get props => [source];
194185
}
195186

196187
/// {@template delete_source_requested}

0 commit comments

Comments
 (0)