|
|
@ -78,12 +78,12 @@ export function mutate(source, value) {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @template V
|
|
|
|
* @template V
|
|
|
|
* @param {import('#client').Source<V>} signal
|
|
|
|
* @param {import('#client').Source<V>} source
|
|
|
|
* @param {V} value
|
|
|
|
* @param {V} value
|
|
|
|
* @returns {V}
|
|
|
|
* @returns {V}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function set(signal, value) {
|
|
|
|
export function set(source, value) {
|
|
|
|
var initialized = signal.v !== UNINITIALIZED;
|
|
|
|
var initialized = source.v !== UNINITIALIZED;
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
initialized &&
|
|
|
|
initialized &&
|
|
|
@ -94,11 +94,11 @@ export function set(signal, value) {
|
|
|
|
e.state_unsafe_mutation();
|
|
|
|
e.state_unsafe_mutation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!signal.equals(value)) {
|
|
|
|
if (!source.equals(value)) {
|
|
|
|
signal.v = value;
|
|
|
|
source.v = value;
|
|
|
|
|
|
|
|
source.version = increment_version();
|
|
|
|
|
|
|
|
|
|
|
|
// Increment write version so that unowned signals can properly track dirtiness
|
|
|
|
mark_reactions(source, DIRTY, true);
|
|
|
|
signal.version = increment_version();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the current signal is running for the first time, it won't have any
|
|
|
|
// If the current signal is running for the first time, it won't have any
|
|
|
|
// reactions as we only allocate and assign the reactions after the signal
|
|
|
|
// reactions as we only allocate and assign the reactions after the signal
|
|
|
@ -116,25 +116,23 @@ export function set(signal, value) {
|
|
|
|
(current_effect.f & CLEAN) !== 0 &&
|
|
|
|
(current_effect.f & CLEAN) !== 0 &&
|
|
|
|
(current_effect.f & BRANCH_EFFECT) === 0
|
|
|
|
(current_effect.f & BRANCH_EFFECT) === 0
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if (current_dependencies !== null && current_dependencies.includes(signal)) {
|
|
|
|
if (current_dependencies !== null && current_dependencies.includes(source)) {
|
|
|
|
set_signal_status(current_effect, DIRTY);
|
|
|
|
set_signal_status(current_effect, DIRTY);
|
|
|
|
schedule_effect(current_effect);
|
|
|
|
schedule_effect(current_effect);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (current_untracked_writes === null) {
|
|
|
|
if (current_untracked_writes === null) {
|
|
|
|
set_current_untracked_writes([signal]);
|
|
|
|
set_current_untracked_writes([source]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
current_untracked_writes.push(signal);
|
|
|
|
current_untracked_writes.push(source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mark_reactions(signal, DIRTY, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DEV) {
|
|
|
|
if (DEV) {
|
|
|
|
if (is_batching_effect) {
|
|
|
|
if (is_batching_effect) {
|
|
|
|
set_last_inspected_signal(/** @type {import('#client').ValueDebug} */ (signal));
|
|
|
|
set_last_inspected_signal(/** @type {import('#client').ValueDebug} */ (source));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
for (const fn of /** @type {import('#client').ValueDebug} */ (signal).inspect) fn();
|
|
|
|
for (const fn of /** @type {import('#client').ValueDebug} */ (source).inspect) fn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|