Lists are an ordered collection of items, stored in a CRDT-like data structure. Lists can contain other lists and maps, resolve conflicts automatically, and do their best to preserve user intent while maintaining order.
If you have a room setup, you can create a list:
Like in other parts of Room Service, you should manually listen for updates:
Indexes are handled automatically
What happens if Alice updates something at
i=10 and Bob deletes
i=0. Is Alice's operation incorrectly applied to
i=9 now? No! Behind the scenes, Room Service assigns an ID to every item in the list and automatically figures out which indexes are where on any client.
So no matter who's operation is executed first, the result is the same:
Much like maps, updates to lists return an efficient copy of the list. To add a new item to the end of the list, use push:
To get that item back, use get:
To update the value at an index, use set:
To add something to the middle of a list, use insertAfter:
To delete an item, use delete: