Skip to content

Commit

Permalink
onAfterUpdate handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dimailn committed Oct 13, 2023
1 parent 82470be commit 82ab311
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/descriptors/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ export default {
return
}

const [ok, dataOrErrors] = result
let [ok, dataOrErrors] = result

this.innerLastSaveFailed = !ok

Expand All @@ -749,6 +749,9 @@ export default {

this.setSyncProp('errors', ok ? {} : dataOrErrors)
this.$emit('after-submit')

dataOrErrors = this.executeEffectEventFold('onAfterUpdate', 'resource', dataOrErrors)

if(ok && typeof dataOrErrors === 'object' && dataOrErrors !== null) {
this.setSyncProp('resource', dataOrErrors)
}
Expand Down Expand Up @@ -976,7 +979,8 @@ export default {
'onFailure',
'onSuccess',
'onLoaded',
'onLoadFailure'
'onLoadFailure',
'onAfterUpdate'
]

this.instantiatedEffects = this.$effects.map(({effect, name, api}: Effect) => {
Expand Down
1 change: 1 addition & 0 deletions src/types/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface EffectContextBuiltinListeners {
onUnmounted: (listener: () => void) => void
onAfterLoad: (listener: (event: Event<{resource: any}>) => object) => void
onBeforeSave: (listener: (event: Event<{resource: any}>) => object) => void
onAfterUpdate: (listener: (event: Event<{resource: any}>) => object) => void
onValidate: (listener: (event: Event<{resource: any}>) => boolean) => void
onFailure: (listener: (event: Event<{errors: any}>) => object) => void
onSuccess: (listener: () => void) => void
Expand Down

0 comments on commit 82ab311

Please sign in to comment.