You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture.md
+18-10Lines changed: 18 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -281,19 +281,27 @@ We use the [Elementary](https://pub.dev/packages/elementary) package as our impl
281
281
- Management of stream subscriptions
282
282
- Automatic disposal of all managed resources
283
283
284
+
**Important Naming Convention for Reactive Fields:**
285
+
286
+
All reactive fields in WidgetModel must follow strict naming conventions:
287
+
-**All Notifier/Listenable types** must end with `State` suffix (ValueNotifier, ValueListenable, StateNotifier, ListenableState, EntityStateNotifier)
288
+
-**Stream types** must end with `Stream` suffix (Stream, StreamController, BehaviorSubject)
289
+
-**Private fields must match public getter names** (e.g., `_isLoadingState` for getter `isLoadingState`)
290
+
284
291
```dart
285
-
// Creating notifiers with automatic disposal
286
-
final _dataState = createNotifier<MyData>();
287
-
final _loadingState = createEntityNotifier<MyData>();
288
-
final _textController = createTextEditingController();
292
+
// CORRECT - Following naming conventions
293
+
late final _dataState = createNotifier<MyData>();
294
+
StateNotifier<MyData> get dataState => _dataState;
289
295
290
-
// Creating a notifier from a stream
291
-
final _streamData = createNotifierFromStream<MyData>(model.dataStream);
296
+
late final _isLoadingState = createValueNotifier(false);
297
+
ValueListenable<bool> get isLoadingState => _isLoadingState;
292
298
293
-
// Listening to a stream with automatic disposal
294
-
disposableListen(model.events, (event) {
295
-
// Handle event
296
-
});
299
+
late final _eventsStream = StreamController<Event>.broadcast();
300
+
Stream<Event> get eventsStream => _eventsStream.stream;
301
+
302
+
// WRONG - Missing proper suffixes
303
+
late final _data = createNotifier<MyData>(); // Should be _dataState
304
+
late final _isLoading = createValueNotifier(false); // Should be _isLoadingState
297
305
```
298
306
299
307
-`EntityStateNotifier` - A specialized StateNotifier that encapsulates a three-state model for UI data: loading, error, and content. It's designed for handling async operations and their UI states:
0 commit comments