Repository navigation
feat(solidart): Resource.previousReady / previousError - #179
Conversation
Resource now retains the most recent ready / error state across any number of intervening transitions — the last known-good value, unlike previousState which is only the single prior state. The state setter captures the outgoing ready/error state (gated on trackPreviousValue), normalized to isRefreshing:false since a retained previous state is history, not the in-flight refresh. Getters subscribe reactively via a state read. Useful to keep UI populated across repeated refresh failures: resource().asReady?.value ?? resource.previousReady?.value. flutter_solidart inherits the getters via its Resource subclass; both bumped to 3.0.0-dev.2.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughChangesResource state history
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: 🔵 Low · up to The PR lets applications retain ready data and errors across repeated refresh transitions, but stale values or diagnostic errors may remain visible when a Resource is reused across identity boundaries or when an older asynchronous request completes after a newer or disposed one. The change is mergeable with explicit owner awareness and follow-up around history invalidation and stale completion handling. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (6 skipped: 6 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #179 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 18
Lines 892 907 +15
=========================================
+ Hits 892 907 +15
🚀 New features to boost your workflow:
|
What
Resourcenow exposespreviousReadyandpreviousError— the most recent ready / error state, retained across any number of intervening transitions. UnlikepreviousState(the single prior state, which may be loading/error), these keep a UI populated across even repeated refresh failures:How
statesetter captures the outgoing ready/error state into_previousReady/_previousError, gated ontrackPreviousValue. The snapshot is normalized toisRefreshing: false— a retained previous state is history, not the in-flight refresh (andrefresh()writes anisRefreshing: trueintermediate that would otherwise leave it permanently flagged).state;first to subscribe reactively (same pattern as the basepreviousValue), then return the stored field;nullwhentrackPreviousValueis disabled or before a ready/error state has been superseded.flutter_solidart'sResourcesubclass inherits the getters unchanged; both packages bumped to3.0.0-dev.2(flutter_solidartrequiressolidart: ^3.0.0-dev.2).Tests
.value/.erroracross two consecutive failures (stream-driven);isRefreshingcleared acrossrefresh()failures (Future-driven, exercises_transition); null whentrackPreviousState: false.solidart: 180 tests pass,dart analyze libclean.flutter_solidart: 37 tests pass, analyze clean.Motivation
A downstream
@SolidQueryroster needs to survive a failed background refresh (e.g. right after an invite) without blanking the table.previousStateonly covers a single failure;previousReadycovers any number — no app-level cache needed.Reviewed by 2 adversarial passes (one caught the
isRefreshingstaleness, now fixed + tested).Summary by CodeRabbit
New Features
Chores