Skip to content

Array can return items in the wrong order #36

@jwngr

Description

@jwngr

Since bindAsArray() uses the value callback and then we loop through the keys of the object to add them to the array, there is no guarantee of the order of the elements in the array? This is not correct. We should either (1) make use of the DataSnapshot.forEach() method to properly iterate over the snapshot in order or (2) make use of the child_added, child_removed, and child_changed events instead of the value event. I think (1) makes sense in the short term and (2) makes the most sense in the long term. We should be able to get some performance benefits by doing (2) since then we won't be recreating so many records over and over every time an item is added to the array.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions