@@ -88,17 +88,17 @@ export function set_active_effect(effect) {
88
88
/**
89
89
* When sources are created within a reaction, reading and writing
90
90
* them within that reaction should not cause a re-run
91
- * @type {null | { reaction: Reaction, sources: Source[] } }
91
+ * @type {null | Source[] }
92
92
*/
93
- export let source_ownership = null ;
93
+ export let current_sources = null ;
94
94
95
95
/** @param {Value } value */
96
96
export function push_reaction_value ( value ) {
97
97
if ( active_reaction !== null && active_reaction . f & EFFECT_IS_UPDATING ) {
98
- if ( source_ownership === null ) {
99
- source_ownership = { reaction : active_reaction , sources : [ value ] } ;
98
+ if ( current_sources === null ) {
99
+ current_sources = [ value ] ;
100
100
} else {
101
- source_ownership . sources . push ( value ) ;
101
+ current_sources . push ( value ) ;
102
102
}
103
103
}
104
104
}
@@ -136,6 +136,11 @@ let read_version = 0;
136
136
137
137
export let update_version = read_version ;
138
138
139
+ /** @param {number } value */
140
+ export function set_update_version ( value ) {
141
+ update_version = value ;
142
+ }
143
+
139
144
// If we are working with a get() chain that has no active container,
140
145
// to prevent memory leaks, we skip adding the reaction.
141
146
export let skip_reaction = false ;
@@ -236,7 +241,7 @@ function schedule_possible_effect_self_invalidation(signal, effect, root = true)
236
241
var reactions = signal . reactions ;
237
242
if ( reactions === null ) return ;
238
243
239
- if ( source_ownership ?. reaction === active_reaction && source_ownership . sources . includes ( signal ) ) {
244
+ if ( current_sources ? .includes ( signal ) ) {
240
245
return ;
241
246
}
242
247
@@ -263,7 +268,7 @@ export function update_reaction(reaction) {
263
268
var previous_untracked_writes = untracked_writes ;
264
269
var previous_reaction = active_reaction ;
265
270
var previous_skip_reaction = skip_reaction ;
266
- var previous_reaction_sources = source_ownership ;
271
+ var previous_sources = current_sources ;
267
272
var previous_component_context = component_context ;
268
273
var previous_untracking = untracking ;
269
274
var previous_update_version = update_version ;
@@ -277,7 +282,7 @@ export function update_reaction(reaction) {
277
282
( flags & UNOWNED ) !== 0 && ( untracking || ! is_updating_effect || active_reaction === null ) ;
278
283
active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
279
284
280
- source_ownership = null ;
285
+ current_sources = null ;
281
286
set_component_context ( reaction . ctx ) ;
282
287
untracking = false ;
283
288
update_version = ++ read_version ;
@@ -365,7 +370,7 @@ export function update_reaction(reaction) {
365
370
untracked_writes = previous_untracked_writes ;
366
371
active_reaction = previous_reaction ;
367
372
skip_reaction = previous_skip_reaction ;
368
- source_ownership = previous_reaction_sources ;
373
+ current_sources = previous_sources ;
369
374
set_component_context ( previous_component_context ) ;
370
375
untracking = previous_untracking ;
371
376
update_version = previous_update_version ;
@@ -759,10 +764,7 @@ export function get(signal) {
759
764
760
765
// Register the dependency on the current reaction signal.
761
766
if ( active_reaction !== null && ! untracking ) {
762
- if (
763
- source_ownership ?. reaction !== active_reaction ||
764
- ! source_ownership ?. sources . includes ( signal )
765
- ) {
767
+ if ( ! current_sources ?. includes ( signal ) ) {
766
768
var deps = active_reaction . deps ;
767
769
if ( signal . rv < read_version ) {
768
770
signal . rv = read_version ;
0 commit comments