feat: add onStart/onStop/onSaved/onError callbacks to autosave options#751
Open
ascott18 wants to merge 1 commit into
Open
feat: add onStart/onStop/onSaved/onError callbacks to autosave options#751ascott18 wants to merge 1 commit into
ascott18 wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Deep auto-saves attach and detach auto-save from entities as they enter and leave the object graph (new navigation properties, loaded collections,
$addChild). Today there's no central place to observe the save lifecycle of each individual entity, so reacting to a successful/failed save or knowing when auto-save was attached to a nested entity requires wiring$save.onFulfilled/onRejectedon every entity by hand.What
Adds four optional callbacks to
AutoSaveOptions(usable from both$startAutoSaveand$useAutoSave, on item and list view models):onStart(vm)- invoked per entity as auto-save attaches, including entities attached to the graph after start.onStop(vm)- invoked when auto-save deactivates (explicit$stopAutoSave()or component unmount).onSaved(vm)- invoked after a successful auto-save$save.onError(vm, error)- invoked when an auto-save$savefails.Each callback receives the affected view model, which is essential under
deepsince a single options object is shared across the whole graph.Notes for reviewers
onErrorfires only on actual$saverejections. Saves skipped due to client validation errors (already observable via$hasError) or apredicatedo not invoke it, since no save is attempted.$stopAutoSave()is not recursive: stopping a deep root only firesonStopfor the root. On component unmount,onStopfires for every entity. This is documented in the callback doc comments and the ViewModels docs.ListViewModelcontainer (a list never saves; its items each fire their own).Includes 6 new unit tests covering start/stop/saved/error for both shallow and deep cases, plus CHANGELOG and documentation updates. Full coalesce-vue suite passes (683 tests).