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

insertElement index #18

Open
jonaskello opened this issue Nov 19, 2019 · 0 comments
Open

insertElement index #18

jonaskello opened this issue Nov 19, 2019 · 0 comments

Comments

@jonaskello
Copy link
Member

jonaskello commented Nov 19, 2019

When using insertElement to do optimistic update on the client side cache it would be useful to shomehow be able to determine the index to insert at from the already existing elements in the array.

For example say we should insert this entity:

{ id: 134234, sortNo: 2 }

into this list

[{ id: 344, sortNo: 1 }, { id: 4543, sortNo: 5 }]

The new entity should be inserted at index 1 but this is hard to tell without knowing the existing items in the list.

One way of solving it would be to allow the index parameter to insertElement to be a function that will receive all existing items in the list (or the whole cache) and return the index. This however would make the patch un-serializable as functions cannot be sent across the network. So it would only work in a client-side context.

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

1 participant