Skip to content

Report a memoized distinct view model compared by value - #6

Closed
long1dev wants to merge 1 commit into
mainfrom
feat/memo-distinct-rule
Closed

long1dev wants to merge 1 commit into
mainfrom
feat/memo-distinct-rule

Conversation

@long1dev

@long1dev long1dev commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Adds memo_distinct_needs_identity_equality: a StoreConnector with distinct: true whose converter returns a memoized view model that is freezed with value equality and holds a List, Map, Set or Iterable. Then distinct deep-compares every item on every action, which CLAUDE.md's "Converters run on every action" rules out with @Freezed(equal: false).

It reports three view models on cb-mobile main today: appointment_items.dart:37, invoice_payments_container.dart:36 and selected_invoice_container.dart:48. The cb-mobile MR that pins this release fixes all three, so it ships together with the fix.

Testing

./check.sh passes, with the rule's 11 tests, and the fixture draws it. On cb-mobile main it reports exactly those three, from a root dart analyze.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2

memo_distinct_needs_identity_equality reports a StoreConnector with
distinct: true whose converter returns a Memo value of its view model, when
that view model is @freezed without equal: false and has a list, map, set or
other iterable field. The memo already hands back the same instance while
nothing changed, so freezed's deep == only re-walks every item after each
change. A view model of scalars, or one built anew on every call, is left
alone, as value equality is what serves it.

cb-mobile main has three such view models (appointment_items,
invoice_payments_container, selected_invoice_container), so this needs them
fixed before it lands.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
@long1dev

long1dev commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Closing without merging. The three view models this rule reports in cb-mobile (appointment items, invoice payments, selected invoice) are memoized, and their value equality is deliberate: when the memo recomputes for an unrelated change, the new lists hold the same instances, so comparing them costs one identity check per item and spares the rebuild. With equal: false they would rebuild on every such change. cb-mobile's CLAUDE.md now says when value equality is the right choice.

@long1dev long1dev closed this Nov 3, 2026
@long1dev
long1dev deleted the feat/memo-distinct-rule branch November 3, 2026 23:11
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