Meteor React Publish methods not reactive

Hi

I have a publish method which will return all objects in a collection based on a active property of an object in another collection.
That param is found within the top of the publish method by querying another collection.
This param is then used in the main query for returning elements to loop through on the UI.
The issue is that my collection on the UI will not reactivity update based on the change ’

It will work once but if you change the active property nothing changes so I am thinking it is related to not being reactive on the server side? Is there a package to use that will fix this? Thanks!!

I don’t think Tracker is implemented on the server (?). The server is just an observer of the database, as per the meteor design. Live queries are like real-time pipes from the database to the server, which the server then forwards/splits to various clients. The clients then need a way of telling the view components to change based off of any new information from upstream. This is solved with Tracker.

One thing you could do is set up two observers in the publish function and //do something regarding the result collection based on the added/changed/remove callbacks of the settings collection.

But, this can also be solved by redesigning your schema more efficiently. Is it not an option for you to include the toggle in the result collection? That would make your life easier:

Meteor.publish('posts-active', ()=>{
 return Posts.find({active:true})
})
Meteor.publish('posts-inactive', ()=>{
 return Posts.find({false})
})

A well designed data architecture allows you to avoid problems like this.

1 Like

this package implements Tracker on the server.