#Firebase mobile app
13 messages · Page 1 of 1 (latest)
Just a thought, I haven’t done this project yet as it was added after I had moved through this section and I haven’t come back to it yet. Could the one parameter be an object that includes username and comment and maybe a unique ID?
Is the onValue fn provided by Firebase ? The callback fn accepts a parameter snapshot. How does it get the snapshot ? What is the purpose of allCommentsNotReversed ? Is it like arranging it in the reverse order based on the time it was commented on by someone ? What are you doing in the for loop ?
We have soo many questions as well. That's because your thought process will be turned into your code. But we don't know your thought process. So, we need a good amount of context behind your issue so that we can debug and see where the issue lies.
And thats the reason its ALWAYS better to share link to the code or even better to your entire scrim or repo if you have put it up on GitHub or somewhere 😄
Hi John, I'm just embarking on the js for this project so would love to see this code in a scrim or repo as well. Maybe we can team up and work out a solution together?
Yeah, onValue is provided by firebase, and the purpose of allcommentsnotreversed is to make the newest comments appear first.
Here's my codepen https://codepen.io/john3929492/pen/QWzBdxJ
Thanks!
hey treadly, sure. here's my codepen https://codepen.io/john3929492/pen/QWzBdxJ
Here's the codepen: https://codepen.io/john3929492/pen/QWzBdxJ
I took a quick glance at the codepen. I think the key issue here is that the message and the name should be considered one atomic piece of data, and since you are separating them at submit time, you are creating the synchronization issue. Given the way the onValue event works, there's no way for Firebase to provide the now-separated data in the synchronized fashion you would like.
One solution to this problem would be to keep the message & name together in the same container/collection (whatever Firebase calls data at this level). I don't believe there was any detail in the course on how to do this, but IIRC the instructor did mention that the data can be an object or an array, so it should be possible. You may have to do some digging in the Firebase reference on how to do this.
Alright. Thanks for the valuable input, will try to push an object to firebase see if that works
Really really appreciate you taking the time to check out my code
Hey John, thanks for sharing the code. I haven't looked at it yet.
As @slim folio suggested, that might be the issue
Let me know when you do. Trying to figure out how to make it work still. Thanks forthe help
Ended up being able to fix the issue by pushing an object to firebase ! ty so much