Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dirty data handling #3

Closed
carlobeltrame opened this issue Nov 13, 2020 · 1 comment
Closed

Dirty data handling #3

carlobeltrame opened this issue Nov 13, 2020 · 1 comment

Comments

@carlobeltrame
Copy link
Member

Vuex ORM has an extra plugin to handle dirty data (https://github.com/vuex-orm/plugin-change-flags). We could offer similar functionality for hal-json-vuex.

let book = api.get('/books/1')
book.change({ numPages: 500 }) // New page count is saved in Vuex, but not yet sent to API. isDirty flag is true.
book.save() // All dirty changes are sent back to the API, including response handling (i.e. reset to the dirty state on error, etc.)

Originally posted by @usu in ecamp/ecamp3#507 (comment)

@carlobeltrame
Copy link
Member Author

At the moment we don't have the need for this feature, since the dirty handling logic in our use cases mostly shouldn't affect the state of the whole application (which is defined via the Vuex store). For delete, we already have the deleted eager mechanic in place, but for patch, there are a lot more edge cases (e.g. correct rollback when multiple patch operations are pending, and only some fail when saving to the API).
In cases where changing the Vuex store eagerly / optimistically is necessary before the response of a patch operation arrives, we will introduce #6 instead, which the developer has to use explicitly and handle the consequences himself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants