@@ -6,23 +6,23 @@ export function enableServiceEvents({ service, Model, store, options }): void {
6
6
const debounceMap = {
7
7
addOrUpdateById : { } ,
8
8
removeItemById : { } ,
9
- addOrUpdate ( item ) : void {
9
+ queueAddOrUpdate ( item ) : void {
10
10
const id = getId ( item , options . idField )
11
11
this . addOrUpdateById [ id ] = item
12
12
if ( this . removeItemById . hasOwnProperty ( id ) ) {
13
13
delete this . removeItemById [ id ]
14
14
}
15
- this . debouncedAddOrUpdate ( )
15
+ this . flushAddOrUpdateQueue ( )
16
16
} ,
17
- removeItem ( item ) : void {
17
+ queueRemoval ( item ) : void {
18
18
const id = getId ( item , options . idField )
19
19
this . removeItemById [ id ] = item
20
20
if ( this . addOrUpdateById . hasOwnProperty ( id ) ) {
21
21
delete this . addOrUpdateById [ id ]
22
22
}
23
- this . debouncedRemoveItem ( )
23
+ this . flushRemoveItemQueue ( )
24
24
} ,
25
- debouncedAddOrUpdate : _debounce ( async function ( ) {
25
+ flushAddOrUpdateQueue : _debounce ( async function ( ) {
26
26
const values = Object . values ( this . addOrUpdateById )
27
27
if ( values . length === 0 ) return
28
28
await store . dispatch ( `${ options . namespace } /addOrUpdateList` , {
@@ -31,7 +31,7 @@ export function enableServiceEvents({ service, Model, store, options }): void {
31
31
} )
32
32
this . addOrUpdateById = { }
33
33
} , options . debounceEventsTime || 20 ) ,
34
- debouncedRemoveItem : _debounce ( function ( ) {
34
+ flushRemoveItemQueue : _debounce ( function ( ) {
35
35
const values = Object . values ( this . removeItemById )
36
36
if ( values . length === 0 ) return
37
37
store . commit ( `${ options . namespace } /removeItems` , values )
@@ -55,8 +55,8 @@ export function enableServiceEvents({ service, Model, store, options }): void {
55
55
: store . dispatch ( `${ options . namespace } /${ mutationName } ` , modified )
56
56
} else {
57
57
eventName === 'removed'
58
- ? debounceMap . removeItem ( item )
59
- : debounceMap . addOrUpdate ( item )
58
+ ? debounceMap . queueRemoval ( item )
59
+ : debounceMap . queueAddOrUpdate ( item )
60
60
}
61
61
}
62
62
}
0 commit comments