@@ -86,17 +86,17 @@ export function set_active_effect(effect) {
86
86
/**
87
87
* When sources are created within a reaction, reading and writing
88
88
* them within that reaction should not cause a re-run
89
- * @type {null | [active_reaction : Reaction, sources: Source[]] }
89
+ * @type {null | { reaction : Reaction, sources: Source[] } }
90
90
*/
91
- export let reaction_sources = null ;
91
+ export let source_ownership = null ;
92
92
93
93
/** @param {Value } value */
94
94
export function push_reaction_value ( value ) {
95
95
if ( active_reaction !== null && active_reaction . f & EFFECT_IS_UPDATING ) {
96
- if ( reaction_sources === null ) {
97
- reaction_sources = [ active_reaction , [ value ] ] ;
96
+ if ( source_ownership === null ) {
97
+ source_ownership = { reaction : active_reaction , sources : [ value ] } ;
98
98
} else {
99
- reaction_sources [ 1 ] . push ( value ) ;
99
+ source_ownership . sources . push ( value ) ;
100
100
}
101
101
}
102
102
}
@@ -235,7 +235,12 @@ function schedule_possible_effect_self_invalidation(signal, effect, root = true)
235
235
for ( var i = 0 ; i < reactions . length ; i ++ ) {
236
236
var reaction = reactions [ i ] ;
237
237
238
- if ( reaction_sources ?. [ 1 ] . includes ( signal ) && reaction_sources [ 0 ] === active_reaction ) continue ;
238
+ if (
239
+ source_ownership ?. reaction === active_reaction &&
240
+ source_ownership . sources . includes ( signal )
241
+ ) {
242
+ continue ;
243
+ }
239
244
240
245
if ( ( reaction . f & DERIVED ) !== 0 ) {
241
246
schedule_possible_effect_self_invalidation ( /** @type {Derived } */ ( reaction ) , effect , false ) ;
@@ -257,7 +262,7 @@ export function update_reaction(reaction) {
257
262
var previous_untracked_writes = untracked_writes ;
258
263
var previous_reaction = active_reaction ;
259
264
var previous_skip_reaction = skip_reaction ;
260
- var previous_reaction_sources = reaction_sources ;
265
+ var previous_reaction_sources = source_ownership ;
261
266
var previous_component_context = component_context ;
262
267
var previous_untracking = untracking ;
263
268
@@ -270,7 +275,7 @@ export function update_reaction(reaction) {
270
275
( flags & UNOWNED ) !== 0 && ( untracking || ! is_updating_effect || active_reaction === null ) ;
271
276
active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
272
277
273
- reaction_sources = null ;
278
+ source_ownership = null ;
274
279
set_component_context ( reaction . ctx ) ;
275
280
untracking = false ;
276
281
read_version ++ ;
@@ -358,7 +363,7 @@ export function update_reaction(reaction) {
358
363
untracked_writes = previous_untracked_writes ;
359
364
active_reaction = previous_reaction ;
360
365
skip_reaction = previous_skip_reaction ;
361
- reaction_sources = previous_reaction_sources ;
366
+ source_ownership = previous_reaction_sources ;
362
367
set_component_context ( previous_component_context ) ;
363
368
untracking = previous_untracking ;
364
369
@@ -739,7 +744,10 @@ export function get(signal) {
739
744
740
745
// Register the dependency on the current reaction signal.
741
746
if ( active_reaction !== null && ! untracking ) {
742
- if ( ! reaction_sources ?. [ 1 ] . includes ( signal ) || reaction_sources [ 0 ] !== active_reaction ) {
747
+ if (
748
+ source_ownership ?. reaction !== active_reaction ||
749
+ ! source_ownership ?. sources . includes ( signal )
750
+ ) {
743
751
var deps = active_reaction . deps ;
744
752
if ( signal . rv < read_version ) {
745
753
signal . rv = read_version ;
0 commit comments