Reputation: 1
Let me first say that I am new to firebase. As I have been playing with angularfire for a bit, I noticed that $firebaseArray was kinda slow in my project...
But when I used the console to find when the result from firebase was received , I realized that there was a second before that result was displayed in ionic view after it arrived.
If what i'm saying is not really clear, here is a codepen with the $firebaseArray
var lists = $firebaseArray(ref.child('lists'));
And here is an other [codepen] (sorry can't add more than two links) where I added this line after it
lists = [{"name":"test"}];
There is an alert and console log in both codepen that shows when the data arrived.
What I'm asking is : why is there a second delay after the data has already arrived ?
EDIT :
Because 'slow' does not really mean anything, I took a screenshot of my browser's network for the first codepen, showing how much time was needed to display the data : screenshot
Upvotes: 0
Views: 148
Reputation: 1
Even though I wasn't really looking for it when I found this thread, the answer to my question was given here :
Asynchronous access to an array in Firebase
By the time the browser executes your console.log(userTokens); the data most likely hasn't been loaded yet. So it just prints the object to the console as a placeholder.
By the time it gets to the for loop, the data may or may not yet have been loaded from Firebase.
At some point you clicked the arrow next to the logged userTokens. By that time the data had loaded from Firebase and the console shows the latest data.
So anyway, thank you for your help in trying to answer my question :)
Upvotes: 0