googlearchive / firebase-util

An experimental toolset for Firebase
http://firebase.github.io/firebase-util
MIT License
276 stars 67 forks source link

NormalizedCollection + $firebaseArray #26

Closed cmellinas closed 9 years ago

cmellinas commented 9 years ago

Hi,

This new 0.2 version brings lot of new cool stuffs, thanks,

Is this possible (maybe in the future) to use NormalizedCollection with $firebaseArray ?

$firebaseObject seems to work but not the array.

katowulf commented 9 years ago

Can you be more specific? It should work fine anywhere a Firebase reference works, including $firebaseArray.

cmellinas commented 9 years ago

I can't put a concrete example now (maybe tomorrow).

But I used a NormalizedCollection with two different ref.

Then I called $firebaseArray on norm.ref() (my new ref) and the array was empty (length 0)

However, norm.ref() shows results with $firebaseObject and .on Firebase events

Is it working on this example : http://firebase.github.io/firebase-util/#/toolbox/NormalizedCollection/example/messages ?

If it's the case, my refs should have an other issue. I would try to create a sample tomorrow.

katowulf commented 9 years ago

It's perfectly possible there is a bug here--this is beta software. But I'd need to see a repro streamlined to the specific problem set to investigate.

cmellinas commented 9 years ago

Ok, I will post a specific example tomorrow.

Thanks,

cmellinas commented 9 years ago

Kato,

I created 2 jsiddle showing the issue :

1) this doesn't work: http://jsfiddle.net/cmellinas/Lvot0xaf/

2) this works: http://jsfiddle.net/cmellinas/uxLkv69d/

If I comment the ref.on the array is empty. It seems there is a race competition and the array is sometimes empty.

Have you an idea how to be sure the firebaseArray is full ?

Thanks,

katowulf commented 9 years ago

Interestingly, it works as long as I attach and on('value'...) listener before passing it into $firebaseArray().

http://jsfiddle.net/katowulf/Lvot0xaf/2/

I'll investigate.

cmellinas commented 9 years ago

Yea, it's pretty weird.

Thanks, Kato,

maksymilian-majer commented 9 years ago

I'm experiencing the same issue. The data from $firebaseArray() flashes once into view and then disappears immediately. Attaching on('value' ...), as Kato suggested, works around that problem.

katowulf commented 9 years ago

Fixed this in master. Will be in 0.2.3 release later today.