@@ -88,17 +88,17 @@ export function set_active_effect(effect) {
8888/**
8989 * When sources are created within a reaction, reading and writing
9090 * them within that reaction should not cause a re-run
91- * @type {null | { reaction: Reaction, sources: Source[] } }
91+ * @type {null | Source[] }
9292 */
93- export let source_ownership = null ;
93+ export let current_sources = null ;
9494
9595/** @param {Value } value */
9696export function push_reaction_value ( value ) {
9797 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 ] ;
100100 } else {
101- source_ownership . sources . push ( value ) ;
101+ current_sources . push ( value ) ;
102102 }
103103 }
104104}
@@ -136,6 +136,11 @@ let read_version = 0;
136136
137137export let update_version = read_version ;
138138
139+ /** @param {number } value */
140+ export function set_update_version ( value ) {
141+ update_version = value ;
142+ }
143+
139144// If we are working with a get() chain that has no active container,
140145// to prevent memory leaks, we skip adding the reaction.
141146export let skip_reaction = false ;
@@ -236,7 +241,7 @@ function schedule_possible_effect_self_invalidation(signal, effect, root = true)
236241 var reactions = signal . reactions ;
237242 if ( reactions === null ) return ;
238243
239- if ( source_ownership ?. reaction === active_reaction && source_ownership . sources . includes ( signal ) ) {
244+ if ( current_sources ? .includes ( signal ) ) {
240245 return ;
241246 }
242247
@@ -263,7 +268,7 @@ export function update_reaction(reaction) {
263268 var previous_untracked_writes = untracked_writes ;
264269 var previous_reaction = active_reaction ;
265270 var previous_skip_reaction = skip_reaction ;
266- var previous_reaction_sources = source_ownership ;
271+ var previous_sources = current_sources ;
267272 var previous_component_context = component_context ;
268273 var previous_untracking = untracking ;
269274 var previous_update_version = update_version ;
@@ -277,7 +282,7 @@ export function update_reaction(reaction) {
277282 ( flags & UNOWNED ) !== 0 && ( untracking || ! is_updating_effect || active_reaction === null ) ;
278283 active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
279284
280- source_ownership = null ;
285+ current_sources = null ;
281286 set_component_context ( reaction . ctx ) ;
282287 untracking = false ;
283288 update_version = ++ read_version ;
@@ -365,7 +370,7 @@ export function update_reaction(reaction) {
365370 untracked_writes = previous_untracked_writes ;
366371 active_reaction = previous_reaction ;
367372 skip_reaction = previous_skip_reaction ;
368- source_ownership = previous_reaction_sources ;
373+ current_sources = previous_sources ;
369374 set_component_context ( previous_component_context ) ;
370375 untracking = previous_untracking ;
371376 update_version = previous_update_version ;
@@ -759,10 +764,7 @@ export function get(signal) {
759764
760765 // Register the dependency on the current reaction signal.
761766 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 ) ) {
766768 var deps = active_reaction . deps ;
767769 if ( signal . rv < read_version ) {
768770 signal . rv = read_version ;
0 commit comments