@@ -47,7 +47,7 @@ export function startBatch(): void {
47
47
}
48
48
49
49
export function endBatch ( ) : void {
50
- if ( ! -- batchDepth ) {
50
+ if ( ! -- batchDepth && notifyBufferLength ) {
51
51
processEffectNotifications ( )
52
52
}
53
53
}
@@ -62,39 +62,38 @@ export function link(dep: Dependency, sub: Subscriber): void {
62
62
sub . depsTail = nextDep
63
63
return
64
64
}
65
- const depLastSub = dep . subsTail
65
+ const prevSub = dep . subsTail
66
66
if (
67
- depLastSub !== undefined &&
68
- depLastSub . sub === sub &&
69
- isValidLink ( depLastSub , sub )
67
+ prevSub !== undefined &&
68
+ prevSub . sub === sub &&
69
+ isValidLink ( prevSub , sub )
70
70
) {
71
71
return
72
72
}
73
- const newLink : Link = {
74
- dep,
75
- sub,
76
- prevDep,
77
- nextDep,
78
- prevSub : undefined ,
79
- nextSub : undefined ,
73
+ const newLink =
74
+ ( sub . depsTail =
75
+ dep . subsTail =
76
+ {
77
+ dep,
78
+ sub,
79
+ prevDep,
80
+ nextDep,
81
+ prevSub,
82
+ nextSub : undefined ,
83
+ } )
84
+ if ( nextDep !== undefined ) {
85
+ nextDep . prevDep = newLink
80
86
}
81
87
if ( prevDep === undefined ) {
82
88
sub . deps = newLink
83
89
} else {
84
90
prevDep . nextDep = newLink
85
91
}
86
- if ( dep . subs === undefined ) {
92
+ if ( prevSub === undefined ) {
87
93
dep . subs = newLink
88
94
} else {
89
- const oldTail = dep . subsTail !
90
- newLink . prevSub = oldTail
91
- oldTail . nextSub = newLink
92
- }
93
- if ( nextDep !== undefined ) {
94
- nextDep . prevDep = newLink
95
+ prevSub . nextSub = newLink
95
96
}
96
- sub . depsTail = newLink
97
- dep . subsTail = newLink
98
97
}
99
98
100
99
export function unlink (
@@ -180,7 +179,11 @@ export function propagate(current: Link): void {
180
179
181
180
if ( shouldNotify ) {
182
181
if ( 'notify' in sub ) {
183
- notifyBuffer [ notifyBufferLength ++ ] = sub
182
+ if ( ! batchDepth && ! notifyBufferLength && next === undefined ) {
183
+ sub . notify ( )
184
+ } else {
185
+ notifyBuffer [ notifyBufferLength ++ ] = sub
186
+ }
184
187
} else {
185
188
const subSubs = ( sub as Dependency ) . subs
186
189
if ( subSubs !== undefined ) {
@@ -225,7 +228,7 @@ export function propagate(current: Link): void {
225
228
break
226
229
} while ( true )
227
230
228
- if ( ! batchDepth ) {
231
+ if ( ! batchDepth && notifyBufferLength ) {
229
232
processEffectNotifications ( )
230
233
}
231
234
}
@@ -251,22 +254,6 @@ export function endTracking(sub: Subscriber): void {
251
254
sub . flags &= ~ SubscriberFlags . Tracking
252
255
}
253
256
254
- export function processComputedUpdate (
255
- computed : Computed ,
256
- flags : SubscriberFlags ,
257
- ) : void {
258
- if ( flags & SubscriberFlags . Dirty || checkDirty ( computed . deps ! ) ) {
259
- if ( computed . update ( ) ) {
260
- const subs = computed . subs
261
- if ( subs !== undefined ) {
262
- shallowPropagate ( subs )
263
- }
264
- }
265
- } else {
266
- computed . flags = flags & ~ SubscriberFlags . Pending
267
- }
268
- }
269
-
270
257
export function processEffectNotifications ( ) : void {
271
258
while ( notifyIndex < notifyBufferLength ) {
272
259
const effect = notifyBuffer [ notifyIndex ] !
@@ -348,7 +335,7 @@ export function checkDirty(current: Link): boolean {
348
335
} while ( true )
349
336
}
350
337
351
- function shallowPropagate ( link : Link ) : void {
338
+ export function shallowPropagate ( link : Link ) : void {
352
339
do {
353
340
const sub = link . sub
354
341
const subFlags = sub . flags
0 commit comments