Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

getValue #126

Closed
andrew19881123 opened this issue Sep 7, 2016 · 1 comment
Closed

getValue #126

andrew19881123 opened this issue Sep 7, 2016 · 1 comment
Assignees

Comments

@andrew19881123
Copy link

Hi Eddy, i'm customising the GeoFire-js plugin to fit with nativescript and your plugin and i got into a problem with their .get which is like this:

this.get = function(key) {
   return _firebaseRef.child(key).once("value").then(function(dataSnapshot) {
      var snapshotVal = dataSnapshot.val();
      if (snapshotVal === null) {
        return null;
      } else {
        return decodeGeoFireObject(snapshotVal);
      }
    });
}

I don't think i can use your api to replicate the same functionality for the reason that your plugin's .query doesn't return a promise (for a good reason, it could be a continuos query and the callback has to be called every time something happen with different results), but i don't see the reason to use the callback approach for the singleEvent: true option where a Promise i think is the best fit.

What i propose is to create a getValue that returns a promise and deprecate the singleEvent: true option so that the query will became only for continuous results.
but that is the best idea that came to my mind at 1am... :) what do you think?

@EddyVerbruggen EddyVerbruggen self-assigned this Sep 8, 2016
EddyVerbruggen added a commit that referenced this issue Sep 8, 2016
@EddyVerbruggen
Copy link
Owner

Hey Andrea!

Awesome idea and it was pretty easy to just return the data in the promise as well in case singleEvent is true. Updated the README accordingly.

It's available right away in this GitHub repo, will be part of the next release to npm.

Please give it a spin,
Eddy

EddyVerbruggen added a commit that referenced this issue Apr 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants