Skip to content

Commit 8026d90

Browse files
committed
new: add isSavePending sugar
1 parent a1910f2 commit 8026d90

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/service-module/make-base-model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
200200
get isRemovePending(): boolean {
201201
return this.getGetterWithId('isRemovePendingById') as boolean
202202
}
203+
get isSavePending(): boolean {
204+
return this.getGetterWithId('isSavePendingById') as boolean
205+
}
203206
get isPending(): boolean {
204207
return this.getGetterWithId('isPendingById') as boolean
205208
}

src/service-module/service-module.getters.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ export default function makeServiceGetters() {
126126
isIdPatchPending.includes(id),
127127
isRemovePendingById: ({ isIdRemovePending }: ServiceState) => (id: Id) =>
128128
isIdRemovePending.includes(id),
129-
isPendingById: (state: ServiceState, getters) => (id: Id) =>
129+
isSavePendingById: (state: ServiceState, getters) => (id: Id) =>
130130
getters.isCreatePendingById(id) ||
131131
getters.isUpdatePendingById(id) ||
132-
getters.isPatchPendingById(id) ||
132+
getters.isPatchPendingById(id),
133+
isPendingById: (state: ServiceState, getters) => (id: Id) =>
134+
getters.isSavePendingById(id) ||
133135
getters.isRemovePendingById(id)
134136
}
135137
}

src/service-module/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ export interface Model {
304304
* `Remove` is currently pending on this model
305305
*/
306306
readonly isRemovePending: boolean
307+
/**
308+
* Any of `create`, `update` or `patch` is currently pending on this model
309+
*/
310+
readonly isSavePending: boolean
307311
/**
308312
* Any method is currently pending on this model
309313
*/

0 commit comments

Comments
 (0)