Skip to content

Commit 6866834

Browse files
committed
Fix stale reference
Documentation and formatting fixes
1 parent 007797a commit 6866834

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

packages/dart/lib/src/utils/parse_live_list.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,17 @@ class ParseLiveList<T extends ParseObject> {
154154

155155
// Log lazy loading mode only once during initialization to avoid log spam
156156
if (_debugLoggedInit) {
157-
print('ParseLiveList: Initialized with lazyLoading=${_lazyLoading ? 'on' : 'off'}, preloadedColumns=${_preloadedColumns.isEmpty ? 'none' : _preloadedColumns.join(", ")}');
157+
print(
158+
'ParseLiveList: Initialized with lazyLoading=${_lazyLoading ? 'on' : 'off'}, preloadedColumns=${_preloadedColumns.isEmpty ? 'none' : _preloadedColumns.join(", ")}',
159+
);
158160
_debugLoggedInit = false;
159161
}
160162

161163
// Only restrict fields if lazy loading is enabled AND preloaded columns are specified
162164
// This allows fetching minimal data upfront and loading full objects on-demand
163165
if (_lazyLoading && _preloadedColumns.isNotEmpty) {
164166
final List<String> keys = _preloadedColumns.toList();
165-
167+
166168
// Automatically include order fields to ensure sorting works correctly
167169
if (query.limiters.containsKey('order')) {
168170
keys.addAll(
@@ -174,7 +176,7 @@ class ParseLiveList<T extends ParseObject> {
174176
}),
175177
);
176178
}
177-
179+
178180
query.keysToReturn(keys);
179181
}
180182

@@ -538,7 +540,7 @@ class ParseLiveList<T extends ParseObject> {
538540
final element = _list[index];
539541

540542
// If not yet loaded (happens with lazy loading), trigger loading
541-
// This will only happen once per element due to the loaded flag
543+
// This will only happen once per element due to the loaded and _isLoading flags
542544
if (!element.loaded) {
543545
_loadElementAt(index);
544546
}
@@ -601,7 +603,8 @@ class ParseLiveList<T extends ParseObject> {
601603
_list[index].object = response.results!.first;
602604
} else if (response.error != null) {
603605
// Emit error to the element's stream so listeners can handle it
604-
element.emitError(response.error!, StackTrace.current);
606+
// Use _list[index] to ensure we emit to the current element at this index
607+
_list[index].emitError(response.error!, StackTrace.current);
605608
if (_debug) {
606609
print(
607610
'ParseLiveList: Error loading element at index $index: ${response.error}',
@@ -610,14 +613,13 @@ class ParseLiveList<T extends ParseObject> {
610613
} else {
611614
// Object not found (possibly deleted between initial query and load)
612615
if (_debug) {
613-
print(
614-
'ParseLiveList: Element at index $index not found during load',
615-
);
616+
print('ParseLiveList: Element at index $index not found during load');
616617
}
617618
}
618619
} catch (e, stackTrace) {
619620
// Emit exception to the element's stream
620-
element.emitError(e, stackTrace);
621+
// Use _list[index] to ensure we emit to the current element at this index
622+
_list[index].emitError(e, stackTrace);
621623
if (_debug) {
622624
print(
623625
'ParseLiveList: Exception loading element at index $index: $e\n$stackTrace',

packages/dart/test/src/utils/parse_live_list_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ void main() {
180180

181181
group('ParseLiveList - Stream Creation Bug', () {
182182
test(
183-
'getAt() creates a new stream each time it is called (demonstrates the bug)',
183+
'async* generators create new streams on each call (educational context)',
184184
() async {
185-
// This test demonstrates the architectural issue: getAt() is an async* generator
186-
// that creates a NEW stream every time it's called, rather than returning a
187-
// cached/reusable stream.
185+
// This test demonstrates async* generator behavior that contributed to the bug.
186+
// It's educational context, not a test of the actual ParseLiveList bug.
187+
// The real bug required integration testing with network request monitoring.
188188

189189
// We can't easily test the full ParseLiveList without a real server, but we can
190190
// demonstrate the stream behavior by examining the method signature and behavior.

0 commit comments

Comments
 (0)