Skip to content

Instantly share code, notes, and snippets.

@romelgomez
Last active April 17, 2016 20:19
Show Gist options
  • Save romelgomez/596b5a555bb4fd78174eff339f975707 to your computer and use it in GitHub Desktop.
Save romelgomez/596b5a555bb4fd78174eff339f975707 to your computer and use it in GitHub Desktop.
Firebase is like mongodb, there are cases when you can use the ref.once('value') to get a unsorted object without having synchronization, but when you need a order array of objects, the way to avoid concurrent connections is this:
var fireData = {
locations: {}
};
// Create a synchronized array, and then destroy the synchronization after having the data
var locations = $firebaseArray(FireRef.child('locations').orderByChild('left'));
locations.$loaded()
.then(function () {
fireData.locations = angular.copy(locations);
locations.$destroy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment