Update subscription to Meteor publication

落爺英雄遲暮 提交于 2019-12-11 04:41:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!