Skip to content

Commit 4095019

Browse files
committed
addOrUpdate* actions can be synchronous
1 parent 4bafdc7 commit 4095019

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/service-module/service-module.actions.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function makeServiceActions(service: Service<any>) {
5151
return service
5252
.get(id, params)
5353
.then(async function(item) {
54-
await dispatch('addOrUpdate', item)
54+
dispatch('addOrUpdate', item)
5555
commit('unsetPending', 'get')
5656
return state.keyedById[id]
5757
})
@@ -99,7 +99,7 @@ export default function makeServiceActions(service: Service<any>) {
9999
.create(data, params)
100100
.then(async response => {
101101
if (Array.isArray(response)) {
102-
await dispatch('addOrUpdateList', response)
102+
dispatch('addOrUpdateList', response)
103103
response = response.map(item => {
104104
const id = getId(item, idField)
105105

@@ -112,7 +112,7 @@ export default function makeServiceActions(service: Service<any>) {
112112
if (id != null && tempId != null) {
113113
commit('updateTemp', { id, tempId })
114114
}
115-
response = await dispatch('addOrUpdate', response)
115+
response = dispatch('addOrUpdate', response)
116116

117117
// response = state.keyedById[id]
118118
}
@@ -135,7 +135,7 @@ export default function makeServiceActions(service: Service<any>) {
135135
return service
136136
.update(id, data, params)
137137
.then(async function(item) {
138-
await dispatch('addOrUpdate', item)
138+
dispatch('addOrUpdate', item)
139139
commit('unsetPending', 'update')
140140
return state.keyedById[id]
141141
})
@@ -165,7 +165,7 @@ export default function makeServiceActions(service: Service<any>) {
165165
return service
166166
.patch(id, data, params)
167167
.then(async function(item) {
168-
await dispatch('addOrUpdate', item)
168+
dispatch('addOrUpdate', item)
169169
commit('unsetPending', 'patch')
170170
return state.keyedById[id]
171171
})
@@ -223,7 +223,7 @@ export default function makeServiceActions(service: Service<any>) {
223223
const { qid = 'default', query } = params
224224
const { idField } = state
225225

226-
await dispatch('addOrUpdateList', response)
226+
dispatch('addOrUpdateList', response)
227227
commit('unsetPending', 'find')
228228

229229
const mapItemFromState = item => {
@@ -260,7 +260,7 @@ export default function makeServiceActions(service: Service<any>) {
260260
return response
261261
},
262262

263-
async addOrUpdateList({ state, commit }, response) {
263+
addOrUpdateList({ state, commit }, response) {
264264
const list = response.data || response
265265
const isPaginated = response.hasOwnProperty('total')
266266
const toAdd = []
@@ -311,7 +311,7 @@ export default function makeServiceActions(service: Service<any>) {
311311
* the `create` response returns to create the record. The reference to the
312312
* original temporary record must be maintained in order to preserve reactivity.
313313
*/
314-
async addOrUpdate({ state, commit }, item) {
314+
addOrUpdate({ state, commit }, item) {
315315
const { idField } = state
316316
const id = getId(item, idField)
317317
const existingItem = state.keyedById[id]

0 commit comments

Comments
 (0)