1
- import {
2
- type EffectScope ,
3
- ReactiveEffect ,
4
- getCurrentScope ,
5
- } from '@vue/reactivity'
1
+ import { EffectFlags , type EffectScope , ReactiveEffect } from '@vue/reactivity'
6
2
import {
7
3
type SchedulerJob ,
8
4
currentInstance ,
@@ -17,24 +13,18 @@ import { invokeArrayFns } from '@vue/shared'
17
13
18
14
class RenderEffect extends ReactiveEffect {
19
15
i : VaporComponentInstance | null
20
- scope : EffectScope | undefined
21
- baseJob : SchedulerJob
22
- postJob : SchedulerJob
16
+ job : SchedulerJob
17
+ updateJob : SchedulerJob
23
18
24
19
constructor ( public render : ( ) => void ) {
25
20
super ( )
26
21
const instance = currentInstance as VaporComponentInstance | null
27
- const scope = getCurrentScope ( )
28
- if ( __DEV__ && ! __TEST__ && ! scope && ! isVaporComponent ( instance ) ) {
22
+ if ( __DEV__ && ! __TEST__ && ! this . subs && ! isVaporComponent ( instance ) ) {
29
23
warn ( 'renderEffect called without active EffectScope or Vapor instance.' )
30
24
}
31
25
32
- this . baseJob = ( ) => {
33
- if ( this . dirty ) {
34
- this . run ( )
35
- }
36
- }
37
- this . postJob = ( ) => {
26
+ const job : SchedulerJob = super . scheduler . bind ( this )
27
+ this . updateJob = ( ) => {
38
28
instance ! . isUpdating = false
39
29
instance ! . u && invokeArrayFns ( instance ! . u )
40
30
}
@@ -48,19 +38,19 @@ class RenderEffect extends ReactiveEffect {
48
38
? e => invokeArrayFns ( instance . rtg ! , e )
49
39
: void 0
50
40
}
51
- this . baseJob . i = instance
52
- this . baseJob . id = instance . uid
41
+ job . i = instance
42
+ job . id = instance . uid
53
43
}
54
44
45
+ this . job = job
55
46
this . i = instance
56
- this . scope = scope
57
47
58
48
// TODO recurse handling
59
49
}
60
50
61
51
callback ( ) : void {
62
52
const instance = this . i !
63
- const scope = this . scope
53
+ const scope = this . subs ? ( this . subs . sub as EffectScope ) : undefined
64
54
// renderEffect is always called after user has registered all hooks
65
55
const hasUpdateHooks = instance && ( instance . bu || instance . u )
66
56
if ( __DEV__ && instance ) {
@@ -73,7 +63,7 @@ class RenderEffect extends ReactiveEffect {
73
63
instance . isUpdating = true
74
64
instance . bu && invokeArrayFns ( instance . bu )
75
65
this . render ( )
76
- queuePostFlushCb ( this . postJob )
66
+ queuePostFlushCb ( this . updateJob )
77
67
} else {
78
68
this . render ( )
79
69
}
@@ -84,8 +74,13 @@ class RenderEffect extends ReactiveEffect {
84
74
}
85
75
}
86
76
87
- scheduler ( ) : void {
88
- queueJob ( this . baseJob )
77
+ notify ( ) : void {
78
+ const flags = this . flags
79
+ if ( ! ( flags & EffectFlags . PAUSED ) ) {
80
+ queueJob ( this . job )
81
+ } else {
82
+ this . flags = flags | EffectFlags . NOTIFIED
83
+ }
89
84
}
90
85
}
91
86
0 commit comments