Repository navigation
fix: properly handle function-valued options in store.set - #120
Conversation
🦋 Changeset detectedLatest commit: 01e0f8c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🔄 Incremental Review - Initial CommitCommit: Scope: Initial PR creation - all changes reviewed Code Quality Analysis✅ Core Logic Implementation (
|
Summary
This PR fixes the handling of function-valued options in
store.set()to correctly distinguish between:Problem
Previously,
store.set()would invoke ANY function passed as a value, making it impossible to store function references as state values. This caused issues when trying to store callbacks, handlers, or other function-valued options.Solution
Added logic to detect when a value should be treated as an updater function vs. a function value by checking:
This ensures:
store.set('count', (prev) => prev + 1)store.set('handler', () => 'result')Changes
createBaseApi.ts:44-52to add conditional logic for updater invocationTest Coverage
🤖 Generated with Claude Code