Meteor 1.3, Composers and Subscriptions

Hi,

I’m using Meteor 1.3 to build an app which has a search mechanism. The search component uses a composer which subscribes to a subscription that applies the search criteria on the server, then the composer just does a find({}) to return everything.

However, repeated running of this search with different queries makes the collection return a cumulative set of all previous queries.

Is there ‘best practice’ for this type of thing?

Should I just apply the same selectors on both server and client so it only filters for what is needed, and let the collection just grow without clearing between queries until it’s next unmounted?

Should I run sub.stop() before resubscribing with the new query in the composer? If so, where is best to store the subscription handle? A file global? Pass it into the component to run stop() before the next query is submitted?

Or have I completely missed something terribly obvious because I’ve been staring at this problem for too long?

Thanks!

Does this question help?

Sort of. :slight_smile: I’m using full text search on the server side, so what you’ve suggested is what I’m doing for other search criteria, but won’t be compatible with FTS.

However, I suspect there was some odd caching going on, as I’m not actually seeing duplicate entries anymore. The cleanup occurs as I initially expected it to.

Thanks for responding though!