-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: make immutable option work more correctly #13526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- make sure to not overfire before/afterUpdate - make sure to not fire mutable sources when they were mutated - only show deprecation warning when in runes mode to not clutter up console (this is in line with how we made it in other places) fixes #13454
🦋 Changeset detectedLatest commit: 54033fa 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 |
let props = () => deep_read_state(context.s); | ||
|
||
if (immutable) { | ||
let version = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's used in the derived, and the derived then does equality checks to see whether or not the version has changed. If we had the possibility of accessing the current/previous value within the derived I would do that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooooh gotcha...thanks for the explanation
* @returns {Source<V>} | ||
*/ | ||
/*#__NO_SIDE_EFFECTS__*/ | ||
export function mutable_source(initial_value) { | ||
export function mutable_source(initial_value, immutable = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than doing this, can't we just use the non-mutable source instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because this method additionally adds the source to the before/afterUpdate array, which is necessary in legacy mode
fixes #13454
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint