Hi, and welcome to the forum!
Replace/move/clear/set
The roadmap is not set in stone, so it is possible to re-prioritize if needed.
Just to try to understand the need; I see a few reasons why this can be requested:
- Reducing the number of events. Changing
[1,2,3]
into [2,3,1]
would require 2 events with remove/add, while having a move event would require only one.
- Simplify for the service to describe a mutation, especially when large parts/the entire collection is updated.
- For the sake of the client (and the UI) to better describe how the data transformed into the new state.
Now, if 1 and 2 is your reasons, this can sort of be achieved by sending a system.reset
, but only for the specific resource. This will cause Resgate to refetch that specific resource, compare it with its own cached version, and generate add/remove events that describes the diff, and send those events to the client(s). So, system.reset is a single event to update any changes.
But 3 is different. Maybe the front-end UI wish to do different types of animations depending on the transformation. Maybe to animate a replaced value in a list by cross-fading from the old to the new, while a removed value should have the height of the graphical component collapsing. Or if the entire list is set, you would want to cross-fade the entire list. Those sort of things. A system.reset won’t help you here.
So, the question is, would system.reset work for you, or is it more about better describing the transition for the front-end client?
Resource response
The resource response is to make method calls that returns a resource. This is commonly used when making calls to create resources, as you often want to get that newly created resource back:
client.call('inventory.items', 'create', { name: "Rubber duck", quantity: 20 })
.then(item => console.log(item.name)); // Logs Rubber duck
The client doesn’t know before-hand the resource ID of the newly created resource, but when the service responds with the resource ID, Resgate will fetch that resource and return it to the client in the
response.
The deprecated new call achieved the same, but forced you to use the method name new. Resource response allows you to use any method name.
So you can also use it for letting clients subscribe to resources they don’t know the resource ID for. Maybe, after logging in, you want to get your own user profile, without knowing your own user ID. Eg:
client.call('directory.users', 'getCurrentlyLoggedInUser')
.then(user => console.log(user.name)); // Samuel
That said, you can create resources whenever/however you want. Resource response is just to allow you to send the newly created resource back to the client without it having to make a separate get request directly after.
Hope that clarifies it.
Best regards,
Samuel