Comments (3)
Unfortunately the answer would be no. The library is based off of the official firebase geofire
library and makes multiple queries around the area you selected as well as validates that it is really within the radius you provided. However the turn around time is fairly quick. What I would suggest is to wrap the response.send(result)
in a setTimeout
after maybe 4 seconds? (Maybe more??)
Then as the onKeyEnteredRegistration
is fired push the results into the results
array.
from geofirestore-js.
Here's my ugly solution.
I create a promise with a timer that cancels the query and resolves in 10000ms.
Every time key_entered
is fired, I reset the timer to 500ms.
When ready
fires, I reset the timer to 1000ms.
It needs work, but it my most reliable solution so far, and my function currently returns data for a location with 21 documents in about 1600ms (3700ms on a cold start), and for a location with 0 documents in about 1100ms.*
return new Promise(resolve => {
const geoQuery = geoFirestore.query({
center: geoPoint,
radius: 30
});
let geoQueryTimer = setTimeout(() => {
geoQuery.cancel();
resolve()
}, 10000 );
const onKeyEnteredRegistration = geoQuery.on(
'key_entered',
(key, doc, distance) => {
clearTimeout(geoQueryTimer);
// do stuff with doc
// push to array, etc
geoQueryTimer = setTimeout(() => {
geoQuery.cancel();
resolve()
}, 500 );
}
);
const onReadyRegistration = geoQuery.on(
'ready',
() => {
clearTimeout(geoQueryTimer);
geoQueryTimer = setTimeout(() => {
geoQuery.cancel();
resolve()
}, 1000 );
}
)
}).then(() => {
// return data
});
*edit: Times when testing functions locally in functions shell.
from geofirestore-js.
What if you need to do another Firestore database call within the key_entred event? How do u suggest we do this.
from geofirestore-js.
Related Issues (20)
- Paginating data after fetched HOT 1
- Question - how can I find near documents with each unique radius? HOT 11
- How to write to firestore after geofirestore query HOT 1
- can't write to firestore properly after geofirestore query HOT 1
- StartAt or startAfter support HOT 1
- Query speed HOT 6
- Custom document key HOT 1
- Geoqueries with additional queries? HOT 3
- When querying `near`: `distance` prop is missing when distance is 0 HOT 1
- Support for Firebase JS SDK 9 HOT 9
- customKey not working on read HOT 10
- Pass a custom document ID HOT 1
- Query returning zero results when filtering with where HOT 8
- Support for new firestore 9.x? HOT 1
- runTransaction on a collection (server-side using cloud functions) HOT 1
- firebase geofirestore v9 not working HOT 1
- Bug double removed on a marker HOT 1
- Geofirestore and onSnapshot are giving delayed events - information is not updating properly
- Unsubscribe from GeoQuery.onSnapshot on document deletion HOT 1
- Typescript errors when trying to deploy function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geofirestore-js.