-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Feature: per-instance pending status #528
Feature: per-instance pending status #528
Conversation
Added tests for state, mutations and getters. Still need:
|
Added tests for actions and BaseModel Still need to add documentation. |
A Map would have been nice for that... Maybe when Vue 3 will be the main supported version.... |
I like it! That's pretty awesome. I looked into it and have three annotations:
|
@J3m5 could you help me understand how a map would be used here where an |
Thanks for the feedback @fratzinger !!
Or do you mean the patch/update/remove actions should all handle multi and pass all IDs to
I like this. Should just be an or of create/patch/update pending status? And should we keep
Yeah this should be easy and a straightforward addition. |
okay, perfect. As
I did not think of that. I think that's what the service-wise
It's hard find the cut between to too little and too much sugar 😄 For me
Maybe we can implement this after this PR, I don't know. Let me know, if I can help :) |
Looks exciting, y'all! Let me know when you are ready to merge! |
I've added In my opinion, per-instance error handling should be a separate PR. Marking this ready for review. |
Finally getting this merged. Thank you! This adds huge time-saving features. |
Summary
Adds per-instance, per-method pending status to FeathersVuex per discussion in #518
PR includes new state, new getters, new mutations, new
BaseModel
get
ers, and modifies the actions forcreate
,update
,patch
andremove
to call the new mutations.What Problem am I Solving?
Currently, FeathersVuex tracks
pending
status forcreate
,update
,patch
andremove
per service... but only in an all-or-nothing way. This means that if any model is pending, the status for that service is set. As expressed in #518, it can be useful to have a status for this model is patching and that model is removing, or similar.In my opinion, the most useful new thing in this PR is that the
BaseModel
now has the followingget
ers:isCreatePending
isUpdatePending
isPatchPending
isRemovePending
isPending
-true
if any of the previous four statuses aretrue
Implementation
I decided to use
Array
s ofid
s in the Vuex state for maintaining the pending status. I chose to useArray
s instead ofObject
s because for eachid
, if a method is called multiple times, an Array can track that there are multiple requests in progress and therefore the status will not clear until the last request finishes.I decided to make the status part of the Vuex state instead of part of the Model class to keep the status in-sync between clones and originals. E.g. when a clone is modified and
patch
ed, the original model's status indicates that apatch
is in progress.❤️