kadirahq / subs-manager

Subscriptions Manager for Meteor
MIT License
358 stars 36 forks source link

SubsManager between two subscriptions #81

Open Themandunord opened 8 years ago

Themandunord commented 8 years ago

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...

I post to the meteor forum, but I don't have any solution for the moment. https://forums.meteor.com/t/subsmanager-between-two-subscriptions/26773

@arunoda can you help me ?

Thanks.

Themandunord commented 8 years ago

Any suggestions ?