Hello,
I’m building an app with meteor + react and using subscription parameters to do server side search. So in client I only have collection.find({}) without any params. I can’t do search in client because of high amounts of data and complex queries which are not supported by minimongo.
And the problem is that I can’t “resubscribe” without meteor reactive methods. See code bellow what I mean:
This works:
class {
constructor(props, context)
{
Session.setDefault(“options”, {});Tracker.autorun(function () { Meteor.subscribe("Data", Session.get("options")); }); } FiltersUpdated = (options) => { Session.set("options", options); }
}
This doesn’t work:
class {
constructor(props, context)
{
}FiltersUpdated = (options) => { Meteor.subscribe("Data", options); }
}
The problem is that when I don’t use Tracker it doesn’t resubscribe but creates a new subscription instead. So as a result search data only gets added to client and if items no longer match the filters they don’t get removed. I checked internal server data and indeed multiple subscriptions are created instead of modifying existing one. The first code example runs perfectly fine though but it has a lot of boilerplate code and looks ugly. I bet there must be some kind of way to make the second example work. I guess the subscription in Tracker saves some kind of id to resub later?
Thanks
Offtopic: there is something wrong with code formatting, I couldn’t get it to align properly