Skip to content

track value callback completion in firebaseLoads #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

joenoon
Copy link

@joenoon joenoon commented Oct 29, 2015

use case: no data exists vs data not yet loaded.
scenario: this.bindAsArray(ref, "items"); without firebaseLoads
there is no way to tell why there are no items, which is a problem
if we want to show a "no items" message. if we rely on
items.length == 0 we will see the "no items" message flicker
before the data is loaded.

use case: no data exists vs data not yet loaded.
scenario: this.bindAsArray(ref, "items"); without firebaseLoads
there is no way to tell why there are no items, which is a problem
if we want to show a "no items" message.  if we rely on
items.length == 0 we will see the "no items" message flicker
before the data is loaded.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@joenoon
Copy link
Author

joenoon commented Oct 29, 2015

CLA signed

@jwngr
Copy link

jwngr commented Nov 16, 2015

Apologies for the extreme delay in getting back to you on this one. This PR brings up a really great point / use case which I overlooked. There is an existing workaround in which you can attach your own on('value') listener and wait for that to fire before you get rid of your "Loading..." screen. But it would be nice to have something built into ReactFire for this.

That being said, I'm not sure this is the correct fix for that. It works, but I'm not a huge fan of the API, specifically the extra firebaseLoads variable. I think it should be more straight-forward. What do you think about setting this.data[bindVar] to undefined in both the array and object case before we have any data? Currently, we already leave this.data[bindVar] as undefined in the object case so you can actually tell when it loads. This seems logical to me. Setting to null would be worrisome since null is the value if there is no data there, so you wouldn't be able to distinguish between those two cases in the object case. I think undefined may be the way to go. In which case, we may just need to move this logic into the on('child_added') listener callback since it will fire before on('value'). We need some special logic to see if this.data[bindVar] is undefined and, if so, initialize it to [].

If you are willing to update your PR, that would be awesome. Otherwise, I opened #74 to track this and will hopefully get to it next time I have a ReactFire coding session.

@jwngr jwngr closed this Jan 12, 2016
@FirebaseExtended FirebaseExtended locked and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants