@@ -21,8 +21,6 @@ class VueView<V> implements Output {
21
21
22
22
#state: State
23
23
24
- #pendingChanges: Change [ ] = [ ]
25
-
26
24
constructor (
27
25
input : Input ,
28
26
onTransactionCommit : ( cb : ( ) => void ) => void ,
@@ -31,7 +29,6 @@ class VueView<V> implements Output {
31
29
queryComplete : true | Promise < true > ,
32
30
) {
33
31
this . #input = input
34
- onTransactionCommit ( this . #onTransactionCommit)
35
32
this . #format = format
36
33
this . #onDestroy = onDestroy
37
34
this . #state = reactive ( [
@@ -40,7 +37,9 @@ class VueView<V> implements Output {
40
37
] )
41
38
input . setOutput ( this )
42
39
43
- this . #applyChanges( input . fetch ( { } ) , node => ( { type : 'add' , node } ) )
40
+ for ( const node of input . fetch ( { } ) ) {
41
+ this . #applyChange( { type : 'add' , node } )
42
+ }
44
43
45
44
if ( queryComplete !== true ) {
46
45
void queryComplete . then ( ( ) => {
@@ -61,30 +60,18 @@ class VueView<V> implements Output {
61
60
this . #onDestroy( )
62
61
}
63
62
64
- #onTransactionCommit = ( ) => {
65
- this . #applyChanges( this . #pendingChanges, c => c )
66
- }
67
-
68
- #applyChanges< T > ( changes : Iterable < T > , mapper : ( v : T ) => Change ) : void {
69
- try {
70
- for ( const change of changes ) {
71
- applyChange (
72
- this . #state[ 0 ] ,
73
- mapper ( change ) ,
74
- this . #input. getSchema ( ) ,
75
- '' ,
76
- this . #format,
77
- )
78
- }
79
- }
80
- finally {
81
- this . #pendingChanges = [ ]
82
- }
63
+ #applyChange( change : Change ) : void {
64
+ applyChange (
65
+ this . #state[ 0 ] ,
66
+ change ,
67
+ this . #input. getSchema ( ) ,
68
+ '' ,
69
+ this . #format,
70
+ )
83
71
}
84
72
85
73
push ( change : Change ) : void {
86
- // Delay setting the state until the transaction commit.
87
- this . #pendingChanges. push ( change )
74
+ this . #applyChange( change )
88
75
}
89
76
}
90
77
0 commit comments