Skip to content

Commit 763ed35

Browse files
committed
simplify
1 parent c55a698 commit 763ed35

File tree

3 files changed

+13
-33
lines changed

3 files changed

+13
-33
lines changed

packages/svelte/src/internal/client/reactivity/effects.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ import {
66
update_effect,
77
get,
88
is_destroying_effect,
9-
is_flushing_effect,
109
remove_reactions,
1110
schedule_effect,
1211
set_active_reaction,
1312
set_is_destroying_effect,
14-
set_is_flushing_effect,
1513
set_signal_status,
1614
untrack,
17-
skip_reaction,
1815
untracking
1916
} from '../runtime.js';
2017
import {
@@ -118,17 +115,12 @@ function create_effect(type, fn, sync, push = true) {
118115
}
119116

120117
if (sync) {
121-
var previously_flushing_effect = is_flushing_effect;
122-
123118
try {
124-
set_is_flushing_effect(true);
125119
update_effect(effect);
126120
effect.f |= EFFECT_RAN;
127121
} catch (e) {
128122
destroy_effect(effect);
129123
throw e;
130-
} finally {
131-
set_is_flushing_effect(previously_flushing_effect);
132124
}
133125
} else if (fn !== null) {
134126
schedule_effect(effect);

packages/svelte/src/internal/client/reactivity/sources.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
derived_sources,
1515
set_derived_sources,
1616
check_dirtiness,
17-
set_is_flushing_effect,
18-
is_flushing_effect,
1917
untracking
2018
} from '../runtime.js';
2119
import { equals, safe_equals } from './equality.js';
@@ -202,22 +200,18 @@ export function internal_set(source, value) {
202200

203201
if (DEV && inspect_effects.size > 0) {
204202
const inspects = Array.from(inspect_effects);
205-
var previously_flushing_effect = is_flushing_effect;
206-
set_is_flushing_effect(true);
207-
try {
208-
for (const effect of inspects) {
209-
// Mark clean inspect-effects as maybe dirty and then check their dirtiness
210-
// instead of just updating the effects - this way we avoid overfiring.
211-
if ((effect.f & CLEAN) !== 0) {
212-
set_signal_status(effect, MAYBE_DIRTY);
213-
}
214-
if (check_dirtiness(effect)) {
215-
update_effect(effect);
216-
}
203+
204+
for (const effect of inspects) {
205+
// Mark clean inspect-effects as maybe dirty and then check their dirtiness
206+
// instead of just updating the effects - this way we avoid overfiring.
207+
if ((effect.f & CLEAN) !== 0) {
208+
set_signal_status(effect, MAYBE_DIRTY);
209+
}
210+
if (check_dirtiness(effect)) {
211+
update_effect(effect);
217212
}
218-
} finally {
219-
set_is_flushing_effect(previously_flushing_effect);
220213
}
214+
221215
inspect_effects.clear();
222216
}
223217
}

packages/svelte/src/internal/client/runtime.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ let last_scheduled_effect = null;
5353
export let is_flushing_effect = false; // TODO do we still need this?
5454
export let is_destroying_effect = false;
5555

56-
/** @param {boolean} value */
57-
export function set_is_flushing_effect(value) {
58-
is_flushing_effect = value;
59-
}
60-
6156
/** @param {boolean} value */
6257
export function set_is_destroying_effect(value) {
6358
is_destroying_effect = value;
@@ -552,8 +547,10 @@ export function update_effect(effect) {
552547

553548
var previous_effect = active_effect;
554549
var previous_component_context = component_context;
550+
var previously_flushing_effect = is_flushing_effect;
555551

556552
active_effect = effect;
553+
is_flushing_effect = true;
557554

558555
if (DEV) {
559556
var previous_component_fn = dev_current_component_function;
@@ -595,6 +592,7 @@ export function update_effect(effect) {
595592
} catch (error) {
596593
handle_error(error, effect, previous_effect, previous_component_context || effect.ctx);
597594
} finally {
595+
is_flushing_effect = previously_flushing_effect;
598596
active_effect = previous_effect;
599597

600598
if (DEV) {
@@ -646,9 +644,6 @@ function infinite_loop_guard() {
646644
}
647645

648646
function flush_queued_root_effects() {
649-
var previously_flushing_effect = is_flushing_effect;
650-
is_flushing_effect = true;
651-
652647
try {
653648
var flush_count = 0;
654649

@@ -674,7 +669,6 @@ function flush_queued_root_effects() {
674669
}
675670
}
676671
} finally {
677-
is_flushing_effect = previously_flushing_effect;
678672
is_flushing = false;
679673

680674
last_scheduled_effect = null;

0 commit comments

Comments
 (0)