Open mxdmedia opened 5 years ago
Hey there!
I'm a new (and temporary) addition to the team here, and I just wanted to hop in and tell you we're looking into this and have done a bit of brainstorming on the subject. Unfortunately, we don't have anything concrete we can share just yet, but we'll keep you in the loop when that changes.
Thanks for your time! :)
@mxdmedia Thanks for the feature request. We are brainstorming the best option here, as we do agree partial updates are a very useful feature. The key in how to do it revolves around the entity key, as we need it to find the right entity to update.
We are not yet sure if we just want to make partial update of existing entities in state the default behavior, or whether to make that an explicit request on the developer's part (which will likely just end up being another optional parameter to the existing Update actions.)
Since we have already separated the concept of Replace vs. Update, it may simply come down to updates by default always allowing partial, fundamental to their nature, with Replace being the way of updating an object in state (and in your remote store) with an entirely new and different version/copy.
@mxdmedia I am considering something along the lines of a PatchEntities
generic action to support this scenario. There are a very wide range of possibilities with auto-entity, and in the long run I think most apps beyond the most basic that need pure entity functionality will be blending auto-entity and raw ngrx to some degree or another.
I'd like to limit how much we add to auto-entity, however I do understand that there will be cases where custom effects need to involve custom ngrx actions, or other auto-entity actions, and the need to custom patch data in the auto-entity state.
To that end, I think a general use PatchEntities
and/or PatchEntity
action would serve this purpose well. This would be an action that is outside of any standard auto-entity flow, and it's entire purpose would be to allow you the developer to introduce data patches to auto-entity managed state for any entity, from an effect...or just by dispatching it yourself. PatchEntities
would allow you to do basically what you've done with your proposed PartialUpdateSuccess
.
This feature still needs thought and review, but it is a feature I think we could add fairly quickly once we get all the details sorted out.
Still using and really happy about how auto-entity works! As you may have gathered from my prior issues, some of the entities I am using are a bit on the complex side. In the past, with the vanilla ngrx entity library, I utilized their partial update options quite a bit. I am wondering if such functionality might be within the realm of your plans for auto entity? For example, lets say I have the following models/entities:
If I update something related to the job, say add an employee on the job for a specific date, my API returns, along with the new
JobEmployee
data, an updatedjobActiveDates
for the job. Its return looks something like this:Currently, in my effect, i need to pull the job from the store, update the dates, then submit the updated job via
UpdateSuccess()
. I would be nice to have a utility action, sayPartialUpdateSuccess()
that takes an object with the Key, and fields to be updated. So I could do something like the following in my effect:Thoughts?