select function in signal reactive scope #366
Openbenjavicente(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/366/headopened - packages/solid-store/src/useSelector.ts lines 62 to 64Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -49,10 +46,18 @@46+ const [version, setVersion] = createSignal(0)494750- const unsubscribe = source.subscribe((snapshot) => {51- setSignal(() => selector(snapshot))48+ const unsubscribe = source.subscribe(() => {49+ setVersion((current) => current + 1)5250 }).unsubscribe53515452 onCleanup(() => {5553 unsubscribe()5654 })575558- return signal56+ return createMemo(57+ () => {58+ version()59+ return selector(source.get())60+ },61+ {62+ equals: compare,63+ },
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID:
4013374a-0a96-4156-979c-55a3fefabb6e📥 Commits
Reviewing files that changed from the base of the PR and between 0a1df5b1c13a6e51430ee200e33999eae3ad83d3 and 4a66c654353b90db3ffa84195370a12244112f77.
📒 Files selected for processing (2)
packages/solid-store/src/useSelector.tspackages/solid-store/tests/index.test.tsx🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.
📝 Walkthrough
Walkthrough#
useSelectornow re-evaluates selectors in Solid, Svelte, and Vue reactive scopes after store notifications. The implementations preserve matching selection references. Tests cover store updates and switching between reactivewidthandheightselections.Changes#
Reactive selector tracking
packages/solid-store/src/useSelector.ts,packages/solid-store/tests/index.test.tsxuseSelectornow invalidates a memo after source notifications and evaluates the selector against the current store value. Tests cover reactive branch changes betweenwidthandheight.packages/svelte-store/src/useSelector.svelte.ts,packages/svelte-store/tests/*useSelectornow uses subscription-driven versioning and$derived.by, with subscription cleanup on destruction. Tests cover store updates and reactive branch changes.packages/vue-store/src/useSelector.ts,packages/vue-store/tests/index.test.tsxuseSelectornow uses a version counter andcomputedto re-evaluate the selector. Matching comparisons preserve the previous selection reference.packages/react-store/tests/index.test.tsx,.changeset/upset-turtles-dress.mdPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ 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.
❤️ Share