Pregunta

So I'm creating a project where people can work together on a task list. My current method of synchronization is pretty bad so I've been wanting to move to GoInstant for a while. As I was looking around I found out about GoAngular, which seems to provide a really sweet, intuitive way to bind together the data and display. However I do not know if GoAngular will be up to the task of handling multiple people adding deleting and reordering items at the same time.

Do you know of a way to make GoAngular support reordering? It is important that updates be incremental and not recreate the DOM of the whole list every time.

¿Fue útil?

Solución

It really depends on the size of your list, you can take two approaches (neither is perfect), both involves adding a position property to your GoAngular model (or creating a model specifically to track positions):

Let's make this our starting point:

[
 { title: 'Item A', position: 1 },
 { title: 'Item B', position: 2 },
 { title: 'Item C', position: 3 },
 { title: 'Item D', position: 4 },
]

If the list is small (in the hundreds of items), you can update positions as they change, so if 'Item B' was moved after 'Item C', you would update the position (using $set) for items B & C:

[
 { title: 'Item A', position: 1 },
 { title: 'Item C', position: 2 },
 { title: 'Item B', position: 3 },
 { title: 'Item D', position: 4 },
]

Alternatively you could insert an item in the middle of two positions, this is more practical in large lists. If 'Item B' was again moved after 'Item C', you would update the position of only 'Item B'. In this example it would be (3+4) / 2 = 3.5:

[
 { title: 'Item A', position: 1 },
 { title: 'Item C', position: 3 },
 { title: 'Item B', position: 3.5 },
 { title: 'Item D', position: 4 },
]

Does that help?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top