cleanup signals code a bit (#10346)

pull/10348/head
Dominic Gannaway 5 months ago committed by GitHub
parent dc8ca4661f
commit d6fa5c7f97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -327,6 +327,7 @@ function is_signal_dirty(signal) {
*/
function execute_signal_fn(signal) {
const init = signal.i;
const flags = signal.f;
const previous_dependencies = current_dependencies;
const previous_dependencies_index = current_dependencies_index;
const previous_untracked_writes = current_untracked_writes;
@ -334,7 +335,7 @@ function execute_signal_fn(signal) {
const previous_block = current_block;
const previous_component_context = current_component_context;
const previous_skip_consumer = current_skip_consumer;
const is_render_effect = (signal.f & RENDER_EFFECT) !== 0;
const is_render_effect = (flags & RENDER_EFFECT) !== 0;
const previous_untracking = current_untracking;
current_dependencies = /** @type {null | import('./types.js').Signal[]} */ (null);
current_dependencies_index = 0;
@ -342,7 +343,7 @@ function execute_signal_fn(signal) {
current_consumer = signal;
current_block = signal.b;
current_component_context = signal.x;
current_skip_consumer = !is_flushing_effect && (signal.f & UNOWNED) !== 0;
current_skip_consumer = !is_flushing_effect && (flags & UNOWNED) !== 0;
current_untracking = false;
// Render effects are invoked when the UI is about to be updated - run beforeUpdate at that point
@ -412,6 +413,10 @@ function execute_signal_fn(signal) {
if (consumers === null) {
dependency.c = [signal];
} else if (consumers[consumers.length - 1] !== signal) {
// TODO: should this be:
//
// } else if (!consumers.includes(signal)) {
//
consumers.push(signal);
}
}
@ -970,7 +975,7 @@ export function get(signal) {
) {
if (current_dependencies === null) {
current_dependencies = [signal];
} else if (signal !== current_dependencies[current_dependencies.length - 1]) {
} else {
current_dependencies.push(signal);
}
}

Loading…
Cancel
Save