SubsManager between two subscriptions

Hi,

I use SubsManager to cache subscription on the client.
But something went wrong.

I have an Artworks collection with two publish methods :

Meteor.publish('artwork', function (artwork_pubsId) {
        return Artworks.find(artwork_pubsId);
});

Meteor.publish('artworks_preview', function () {
    return Artworks.find({}, {fields: {description: 0}, limit : 2});
});

I have two components with React with container :

const ArtworkSubs = new SubsManager();

export const composer = ({context}, onData) => {
  const {Meteor, Collections} = context();

  if (UserSubs.subscribe('user_home_preview').ready() && ArtworkSubs.subscribe('artworks_preview').ready()) {
    const users = Meteor.users.find().fetch();
    const artworks = Collections.Artworks.find().fetch();
    onData(null, {users : users, artworks : artworks});
  }
//...

And

const ArtworkSubs = new SubsManager();

export const composer = ({context,id}, onData) => {
  const {Meteor, Collections, FlowRouter} = context();

    if(ArtworkSubs.subscribe('artwork',id).ready()){
       const artwork = Collections.Artworks.find({}).fetch();
//...

First component hide description field of the artworks.
So when I go to an artwork page with the first publish, I don’t have the description field…
If I go directly to the artwork page, I have this description, and when I go to the home page all artworks have this description field.

How can I do to have the good information in the good place ?
I need SubsManager to keep data in client cached to go back an auto scroll to the previous position…

Thanks.

In the artwork preview pub you are not publishing the description field.

Yeah it’s all right. But it’s the good behavior.

On my home page, I don’t need the description field, so I subscribe with the artwork preview sub.
When I click on an artwork, I go to the single artwork page, so I subscribe to the artwork sub (with the description field).

But because the cache it’s active, the artwork sub don’t get the description field (I suppose…)

Hi,

Any idea for my problem?

I up this thread, because my question is not answered yet.

It seems to me that you have a conflict. Are you subscribing to the same collection with same ids twice?

Yeah, I subscribe to the same collection but not with the same publication.

The artwork_preview doesn’t publish the description field, so when I go the artwork view, I subscribe to the artwork publication (which publish everything) and I don’t have the description field because of the subs manager cache.

That could be the problem. Mini mongo (local web version of Mongo with data caching) only sees a collection. It doesn’t care which publication sent it. So when you have an overlap of content, most likely the most recent pull is what is reflected.

We can use different simultaneous publications on the same collection when there is no overlap.

To test this idea, disable one and see result, switch pubs and try again.

1 Like

If that does turn out to be the case, you could look at using percolate:find-from-publication whiche lets you identify which documents came from which publications.

Thanks for your answers !

I will look a it when I have time for it, I think in the end of the week.