I have a simple project in React. I’ve run into an issue regarding multiple subscriptions to the same publication in different view layers.
The basic structure is a MainLayout Component, with a NavigationBar component, and also a content prop to render my individual ‘pages’.
One of these ‘pages’ contains a subscription:
Meteor.subscribe('example')
to publication:
Meteor.publish('example', (query) => { if (query) { let regex = new RegExp(query, 'i'); return Example.find({field: regex}) } else { return Example.find({}) } })
As you can see the page returns the whole collection, since there is no argument specified.
I now want to implement a search function in my NavigationBar component. This will supply an argument to the subscription so that only the matched documents will be returned.
However because the collection I am searching through is the same as the one that I am subscribing to in the content, I keep getting the entire collection returned when performing the search. It seems the filtered subscription result is overridden by
Meteor.subscribe('example')
Is this expected behaviour? Is the only way to resolve this to move these two subscriptions into separate renders?
Thanks.