Last active
April 17, 2016 20:19
-
-
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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