chore: remove ignore_mutation_validation (#10789)

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/10793/head
Rich Harris 10 months ago committed by GitHub
parent 2701c0ad64
commit bd687c6504
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -8,7 +8,6 @@ import {
current_untracking,
flushSync,
get,
ignore_mutation_validation,
is_batching_effect,
is_runes,
mark_reactions,
@ -19,7 +18,7 @@ import {
untrack
} from '../runtime.js';
import { equals, safe_equals } from './equality.js';
import { CLEAN, DERIVED, DIRTY, MANAGED } from '../constants.js';
import { CLEAN, DERIVED, DIRTY, MANAGED, UNINITIALIZED } from '../constants.js';
/**
* @template V
@ -93,9 +92,11 @@ export function mutate(source, value) {
* @returns {V}
*/
export function set(signal, value) {
var initialized = signal.v !== UNINITIALIZED;
if (
!current_untracking &&
!ignore_mutation_validation &&
initialized &&
current_reaction !== null &&
is_runes() &&
(current_reaction.f & DERIVED) !== 0
@ -124,11 +125,10 @@ export function set(signal, value) {
//
// $effect(() => x++)
//
// We additionally want to skip this logic for when ignore_mutation_validation is
// true, as stores write to source signal on initialisation.
// We additionally want to skip this logic when initialising store sources
if (
is_runes() &&
!ignore_mutation_validation &&
initialized &&
current_effect !== null &&
(current_effect.f & CLEAN) !== 0 &&
(current_effect.f & MANAGED) === 0

@ -1,7 +1,7 @@
import { subscribe_to_store } from '../../../store/utils.js';
import { noop } from '../../common.js';
import { UNINITIALIZED } from '../constants.js';
import { get, set_ignore_mutation_validation, untrack } from '../runtime.js';
import { get, untrack } from '../runtime.js';
import { user_effect } from './effects.js';
import { mutable_source, set } from './sources.js';
@ -74,13 +74,7 @@ function connect_store_to_signal(store, source) {
return noop;
}
/** @param {V} v */
const run = (v) => {
set_ignore_mutation_validation(true);
set(source, v);
set_ignore_mutation_validation(false);
};
return subscribe_to_store(store, run);
return subscribe_to_store(store, (v) => set(source, v));
}
/**

@ -84,12 +84,6 @@ export function set_last_inspected_signal(signal) {
/** If `true`, `get`ting the signal should not register it as a dependency */
export let current_untracking = false;
/** Exists to opt out of the mutation validation for stores which may be set for the first time during a derivation */
export let ignore_mutation_validation = false;
/** @param {boolean} value */
export function set_ignore_mutation_validation(value) {
ignore_mutation_validation = value;
}
// If we are working with a get() chain that has no active container,
// to prevent memory leaks, we skip adding the reaction.

Loading…
Cancel
Save