Nested reactive publish

Continuing the discussion from Nested document not reactive:

I’m trying my make my publish function reactive when relationships change - in some cases, the ParentCollection.childID field may change but the published content is not automatically updated to reflect this change.

Meteor.publish('nestedExample', function() {
  var child_ids = _.pluck(ParentCollection
        .find({}, {fields: {childID: 1}})
        .fetch(), 'childID');
    return [
      ParentCollection.find({}),
      ChildCollection.find({_id: {$in: child_ids}}),
    ];
});

Any idea how to make that part reactive?

use publish composite, or code it yourself in low level publish API.

See:
https://www.discovermeteor.com/blog/reactive-joins-in-meteor/

1 Like