问题
I am in an Ionic2 / Angular2 project using a Meteor Database. I have a Collection of Points and want to show them on a map. Every time the map-view changes, I set a new query with the new bounds. This is working quite fine already.
But the collection is already really huge, so I have to reduce the publication as it slows down my app a lot. I want to restrict it also to the bounds of the shown area. So I need to update the subscription every time I send a new query. My code looks like this:
MeteorObservable.subscribe('area-points', bounds).subscribe(() => {
MeteorObservable.autorun().subscribe(() => {
this.allPoints = <Observable<Point[]>>this.searchArea
.debounceTime(1000)
.distinctUntilChanged()
.switchMap((bounds: L.LatLngBounds) => {
//update the bounds of the subscription here
return Point.find({ /* bounds */ });
});
});
});
Can someone point me out, how to update the outer subscription? I found an answer on another post that looks really good, but I don't know how to use it here for my project: https://stackoverflow.com/a/34558520/1904790
Thank you very much for helping.
来源:https://stackoverflow.com/questions/42073785/update-subscription-to-meteor-publication