Skip to content

feat(solidart): Resource.previousReady / previousError - #179

Merged
nank1ro merged 1 commit into
mainfrom
feat/resource-previous-ready-error
Aug 28, 2026
Merged

nank1ro merged 1 commit into
mainfrom
feat/resource-previous-ready-error

Conversation

@nank1ro

@nank1ro nank1ro commented Aug 28, 2026 •

Copy link
Copy Markdown
Owner

What

Resource now exposes previousReady and previousError — the most recent ready / error state, retained across any number of intervening transitions. Unlike previousState (the single prior state, which may be loading/error), these keep a UI populated across even repeated refresh failures:

resource().asReady?.value ?? resource.previousReady?.value

How

  • The state setter captures the outgoing ready/error state into _previousReady / _previousError, gated on trackPreviousValue. The snapshot is normalized to isRefreshing: false — a retained previous state is history, not the in-flight refresh (and refresh() writes an isRefreshing: true intermediate that would otherwise leave it permanently flagged).
  • Getters read state; first to subscribe reactively (same pattern as the base previousValue), then return the stored field; null when trackPreviousValue is disabled or before a ready/error state has been superseded.
  • flutter_solidart's Resource subclass inherits the getters unchanged; both packages bumped to 3.0.0-dev.2 (flutter_solidart requires solidart: ^3.0.0-dev.2).

Tests

  • New tests: retain .value/.error across two consecutive failures (stream-driven); isRefreshing cleared across refresh() failures (Future-driven, exercises _transition); null when trackPreviousState: false.
  • solidart: 180 tests pass, dart analyze lib clean. flutter_solidart: 37 tests pass, analyze clean.

Motivation

A downstream @SolidQuery roster needs to survive a failed background refresh (e.g. right after an invite) without blanking the table. previousState only covers a single failure; previousReady covers any number — no app-level cache needed.

Reviewed by 2 adversarial passes (one caught the isRefreshing staleness, now fixed + tested).

Summary by CodeRabbit

  • New Features

    • Resources can now retain and expose their most recent ready or error state across refreshes and failures.
    • Retained states include accurate refreshing status and can be disabled when previous-value tracking is not needed.
  • Chores

    • Updated Solidart and Flutter Solidart to version 3.0.0-dev.2.
    • Added release notes describing the previous-state functionality.

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.
@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c3eafb2-cf0c-4d06-9f81-514c8d8a5b16

📥 Commits

Reviewing files that changed from the base of the PR and between 17d9b48 and ffb0555.

📒 Files selected for processing (6)
  • packages/flutter_solidart/CHANGELOG.md
  • packages/flutter_solidart/pubspec.yaml
  • packages/solidart/CHANGELOG.md
  • packages/solidart/lib/src/core/resource.dart
  • packages/solidart/pubspec.yaml
  • packages/solidart/test/solidart_test.dart

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

Changes

Resource state history

Layer / File(s) Summary
Retain and expose previous states
packages/solidart/lib/src/core/resource.dart, packages/solidart/test/solidart_test.dart
Resource retains the latest ready and error snapshots, exposes them through previousReady and previousError, and tests repeated failures, refresh state cleanup, and disabled tracking.
Release metadata alignment
packages/solidart/pubspec.yaml, packages/solidart/CHANGELOG.md, packages/flutter_solidart/pubspec.yaml, packages/flutter_solidart/CHANGELOG.md
Both packages move to 3.0.0-dev.2, and flutter_solidart requires solidart: ^3.0.0-dev.2.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to ffb05

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: medz

Poem

A rabbit checks the states at night
Ready and error, held just right
Refresh flags fade from view
New getters make the history true
Packages hop to three-point-two

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding Resource.previousReady and Resource.previousError.
Docstring Coverage ✅ Passed 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…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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)
  • Create PR with unit tests
  • Commit unit tests in branch feat/resource-previous-ready-error

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from medz August 28, 2026 14:32
@nank1ro
nank1ro removed the request for review from medz August 28, 2026 14:34
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (17d9b48) to head (ffb0555).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #179   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        18           
  Lines          892       907   +15     
=========================================
+ Hits           892       907   +15     
Files with missing lines Coverage Δ
packages/solidart/lib/src/core/resource.dart 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nank1ro
nank1ro merged commit 3710133 into main Aug 28, 2026
4 checks passed
@nank1ro
nank1ro deleted the feat/resource-previous-ready-error branch August 28, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant