0
votes

I'm using subscriptions manager with iron-router and my problem is this one.

I have a collection "participants" with 2 publications: allParticipants and todayParticipants.

if I go to this page:

Router.map(function () {
    this.route('winners', {
        waitOn: function () {
            return [subs.subscribe('allWinners'),
                subs.subscribe('allParticipants')];
            console.log("subscribed!");


        },
        data: function () {
            return {
                winners: Winners.find(),
                participants: Participants.find(),
                loginBox: "True"
                }

        }
    });

AllParticipants publication is subscribed and put in cache by the subscription manager package.

If after this, I go to this page:

Router.map(function () {
    this.route('participants', {
        path: '/',
        waitOn: function () {
            return subs.subscribe('todayParticipants');
        },
        data: function () {
            return {
                participants: Participants.find()
            }
        }
    });

I'm expecting to subscribe only the todayParticipants but as my subscription is automatically named "Participants", It uses the cached subscription from the previous page being allParticipants.

Is there a way to change the name of my subscriptions in order to have each of them in the right cache?

Thanks.

2

2 Answers

0
votes

What I do in my waitOn function is first stop my subscriptions like

 if (App.subs) {
     for (name in App.subs) {
         App.subs[name].stop();
     }
 }

And then I create new subscriptions

App.subs = {
    settings: Meteor.subscribe('settings', project), 
    ...
};

return [App.sub.settings, .....];

Hope this helps!

0
votes

Today, there seems to be no solution to this problem.

More explanation here: https://github.com/meteorhacks/subs-manager/issues/11

What I'm doing now is using a very limited number of subscriptions (filtered mainly on user) and then I create as much data objects as I want filtering my subscriptions in different ways.